0

I am trying to mask a NetCDF file with an shapefile. Here is my shapefile:

Africa_Shape = geopandas.read_file('/content/gdrive/MyDrive/HighresMIP/control_1950/iho/iho.shp', crs="epsg:4326")

And here is my NetCDF file (MSWEP_monthly) structure and the procedure that I am following to clip the original dataset enter image description here

And my results are all the values nan.

1 Answer 1

0

https://github.com/corteva/rioxarray/issues/202

Simplest method:

min_x, min_y, max_x, max_y = Africa_Shape.total_bounds
xds_clipped  = xds.where((xds.lon<=max_x) & (xds.lon>=min_x) & (xds.lat<=max_y) & (xds.lat>=min_y), drop=True)

But, I would recommend looking into xoak

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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