Clip WRF data using shapefile #79
Unanswered
gabrielops84
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The following is not tested, but instead what I would guess to be the case based on the rioxarray docs. Feel free to try it out and report back with any issues! By using xwrf's ds_wrf_processed = ds_wrf.xwrf.postprocess()
ds_wrf_clipped = ds_wrf_processed.rio.clip(geo.geometry.apply(mapping), 'epsg:4326', drop=True) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello fellows! How is it going ?
I'd like to clip precipitation data from WRF output file. Usually I deal with datasets in WGS84 datum where lat lon are 1D arrays coordintes of dataset. Then I apply the following commands using geopandas, xarray and rioxarray:
ds = ds.rio.set_spatial_dims(x_dim=lon_str, y_dim=lat_str, inplace=True)
ds = ds.rio.write_crs('epsg:4326', inplace=True)
ds = ds.rio.clip(geo.geometry.apply(mapping), 'epsg:4326', drop=True)
Where geo is a gemetry shapefile and lat_str and lon_str are labeled names of lat long coordinates and dimensions of dataset like this one:
I'd like to do it on my WRF output file:
But XLAT and XLONG are 3D arrays on lambert conformal conic projection:
'+proj=lcc +lat_0=-23.6999893188477 +lon_0=-43.5 +lat_1=-0.5 +lat_2=-45 +x_0=0 +y_0=0 +R=6370000 +units=m +no_defs'
I'd like to reproject data to WGS84 datum and set latitude and longitude as spatial dims to clip space over time. My WRF file has irregular grid and I think I need to interpolate to a regular grid. I've been searching about projections using pyproj and interpolate using salem. I've found some solutions to plot data but nothing about clip data correctly.
rioxarray.clip method works with 'x' and 'y' as dimension labeled 1D arrays. Can you guys help ? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions