-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
xray methods using shapefile as mask? #501
Copy link
Copy link
Closed
Labels
Description
Can we set a shapefile as a mask for each netcdf file and run xray methods for values within the shapefile region?
for example if I want to create a timeseries of monthly mean temperature for 'mystate' from a netcdf file that contains data for the whole country:
filepath = r"DATA/temp/_/_temp.nc"
shapefile = r"DATA/mystate.shp"
ds=xray.open_mfdataset(filepath)
ds_variable=ds['temp']
monthlymean=ds_variable.resample('1MS', dim='time', how='mean')
meanmonthlyofmystate=monthlymean.groupby('time').mean() #add somewhere here the shapefile
meanmonthlyofmystate.to_pandas().plot()
Reactions are currently unavailable