Clipping a netcdf file with Shapefile in Anaconda produces NaN values #6572
-
I want to clip my netcdf file with the shapefile, the script I run is as below. But my clipped data when I check with Panoply gives the dtr values all NaN. I attached the screenshot here. Please enlighten me on how I can solve this one and where I went wrong. Thanks much. ================================================================================== import xarray
import rioxarray
import geopandas
from shapely.geometry import mapping
xds = xarray.open_dataset("dtr_MON_climpact.sample_historical_NA_1970-1989.nc", drop_variables='time_bnds')
xds.rio.write_crs("EPSG:4326", inplace=True)
geodf = geopandas.read_file("Chauk_BD.shx")
clipped = xds.rio.clip(geodf.geometry.apply(mapping), geodf.crs,drop=False)
clipped.to_netcdf('my clipped data 1.nc') |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@MMon27, can please use the rioxarray discussion forum: https://github.com/corteva/rioxarray/discussions ? |
Beta Was this translation helpful? Give feedback.
-
For anyone interested in this topic, this discussion has been moved to corteva/rioxarray#520 |
Beta Was this translation helpful? Give feedback.
For anyone interested in this topic, this discussion has been moved to corteva/rioxarray#520