1

I have global net radiation data but I want to extract for my country. I've loaded the NetCDF but I don't know how to proceed further. The following is a similar question (Extract data from netcdf using a shapefile polygon in python) but the answer talks about running from command line but I'm using Spyder.

If someone could help me with the code, I know that I need to use some command like clip or extract but I'm not sure how to.

0

You can use rioxarray. Here is an example: https://corteva.github.io/rioxarray/stable/examples/clip_geom.html

import rioxarray
import geopandas

geodf = geopandas.read_file(...)
xds = rioxarray.open_rasterio(...)
clipped = xds.rio.clip(geodf.geometry.apply(mapping), geodf.crs)
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.