- I have a data frame that consists of 3 polygons
- I have a raster with a single band
Seems like Zonal statistics as a table in ArcGIS does the job but I am using pure python script on this one; with no access to ArcPy.
how do I join the raster value (min, max, average, etc.) to the 3 polygons?
import geopandas as gpd
gdf = gpd.read_file("polygons.shp")
print("length of gdf: ", len(gdf))
# length of gdf: 3
def zonstats(gdf, raster_path):
...
...
...
return gdf_joined
Best Answer
You can use
rasterstats.zonal_stats
Example output: