extracting pixel data for individual polygons from a raster using rio.clip() #205
-
I've got an Xarray dataset (ds) of geospatial data (DEMs) and a companion Geopandas geodataframe (gdf) with a geometry column of polygons. I'd like to use the polygons to extract pixel data from the DEMs and have it associated with each row in the geodataframe. I can readily use
but this is quite slow given the size of my raster. In other portions of my code, I've been able to speed up this process by trimming the raster to a buffered bounding box of the geometry prior to clipping. I again need that ability and was about to start turning my existing implementation into a more generalized function. I'm wondering if there's a relevant place/space within rioxarray to house something like this so that I can refactor into a more public space than my own repo. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think you are looking for geocube: https://corteva.github.io/geocube/stable/examples/zonal_statistics.html |
Beta Was this translation helpful? Give feedback.
I think you are looking for geocube: https://corteva.github.io/geocube/stable/examples/zonal_statistics.html