I have a geopackage with a point feature. Which contains points along 19 lines. So, the number of points per line is exactly the same. Therefore, I could see it as a matrix in numpy. Moreover, each point has an attribute "AffectedbyRiver", where 1 (white) and 0 (red). How can a extract that information from geopandas to numpy array as an array 204-by-19 ? I mean, as a matrix with zeros and ones.
Note: The figure below is a screenshot from QGIS3x
import geopandas as gpd
preplot = gpd.read_file('geodatabase.gpkg', layer='SourceRegularPoints')
preplot.plot(figsize=(12,8))
here is my code (manually):
indexline = [19,18,17,16,15,14,13,12,11,10,1,2,3,4,5,6,7,8,9]
array = np.zeros((204,19))
x_coor = np.zeros((204,19))
y_coor = np.zeros((204,19))
for i in indexline:
array[:,i-1]=preplot.loc[preplot['org_fid']==i].AffectedbyRiver.values
x_coor[:,i-1]=preplot.loc[preplot['org_fid']==i].X.values
y_coor[:,i-1]=preplot.loc[preplot['org_fid']==i].y.values
plt.scatter(x_coor.flatten(),y_coor.flatten(),c=array.flatten(),cmap='gray')