I have points shapefile and polygons shapefile. I would like to find out the highest point within each polygon. I have done an intersection to find out which points belong to each polygon:
import geopandas as gpd
from geopandas.tools import sjoin
point = gpd.GeoDataFrame.from_file(pointSHP)
print("POINT", point)
poly = gpd.GeoDataFrame.from_file(polygonSHP)
print("POLY", poly)
points_within_poly = gpd.sjoin(point, poly, how="inner", op='intersects')
print(points_within_poly.head(10))
Now I would like to select the highest point for each index_right. I think is a matter of sorting by Z value in geometry column but I am having problems to do it. I don't know how to extract the Z coordinate from geometry using geopandas. Finally I would like to do a spatial join and populate the Z value to the nearest point (another shapefile).
Thank you
z
from 3D point in your case, just usepoint.geometry[0].z
for the first item in the geo-dataframe. - swatchai