Recommended method for raster to shapefile aggregation?

I searched around a bit but couldn’t quite find if there was a Pangeo-related Python tool for converting data in gridded format (NetCDF/Zarr) to shape-file type of data - for instance, calculating the mean annual temperature for each state in the US (or total rainfall, etc.), using ERA5 or ERA5-Land.

Not sure if there is a straightforward workflow or tool to do this? Would really appreciate any suggestions on this. Thanks!

2 Likes

Try create masks of geographical regions — regionmask 0.8.1.dev0+gc47cc00.d20210908 documentation

2 Likes

Two other packages that people like:

We would love to hear back from which of these packages best met your needs!

5 Likes

Thanks for the suggestion @aaronspring and @rabernat! Will take a look at these tools and see what works well. Absolutely, will provide comments once I’ve had a look.

Searching for zonal stats might help you find some related tools and discussions.
e.g. python - Computing annual spatial (zonal) statistics of a NetCDF file for polygons in shape-file - Geographic Information Systems Stack Exchange

1 Like

xarray-spatial + Datashader can do this, but I see that Zonal — xarray_spatial 0.2.9 documentation is currently showing an error (which I just reported).

2 Likes

FYI - late following up on this (just got around to it a while ago). Salem worked really well for me so thanks again for the suggestion!

The example given was really easy to follow and modify it to my data workflow with ERA5, especially with the sample world borders shape file for me to play with. :+1:

1 Like