I have a point grid generated from a bounding box of a polygon using numpy's meshgrid.
The code is below, but I want to make sure each point has an A or B.
The points in the first row should be labeled A B A B A B A B etc...
The points in the second row should be labeled B A B A B A B A etc...
This should alternate, so all the odd rows should follow the pattern of the first row and all the even rows should follow the pattern in the second row.
minx = min(np.floor(polygon.bounds.minx / grid_res) * grid_res)
maxx = max(np.ceil(polygon.bounds.maxx / grid_res) * grid_res)
miny = min(np.floor(polygon.bounds.miny / grid_res) * grid_res)
maxy = max(np.ceil(polygon.bounds.maxy / grid_res) * grid_res)
# Make a grid
x = np.arange(minx, maxx + grid_res / 2, grid_res)
y = np.arange(miny, maxy + grid_res / 2, grid_res)
x, y = np.meshgrid(x, y)
points = MultiPoint(gpd.points_from_xy(np.ravel(x), np.ravel(y)))
points = gpd.GeoDataFrame(crs=crs, geometry=[points])
points = points.explode(index_parts=True)
It would be handy if the np.meshgrid could assign the A or B, alternatively in Geopandas once the MultiPoint is exploded the point grid could be iterated over row by row.
Which is the best way, and how do I do it?
EDIT
To help:
x = array([388900., 389000., 389100., 389200., 389300., 389400., 389500., 389600., 389700.])
y = array([107800., 107900., 108000., 108100., 108200., 108300., 108400.])