Project

General

Profile

CDO: extract gridcell from netcdf file

Added by Rebekka Estermann about 1 month ago

Hi
I have netcdf files of snow (see attached photo). As you can see the variable prsn (snow) is on a rotated pole grid. There are some additional 2D lon lat coordinates in the file to get from the regular lat lon coordinates to the rlat rlon coordinates.
I want to extract a certain gridcell, however I only have its regular lan lot coordinates (e.g. lat = 46.83, lon = 9.81). I tried a few things (sellonlatbox, leindexbox, mix of python + cdo) to extract the correct (nearest) gridcell from the file, but I didn't manage to do so. Do you know a solution for my problem?
I would appreciate your help. Thank you.

Kind regards,
Rebekka


Replies (3)

RE: CDO: extract gridcell from netcdf file - Added by Uwe Schulzweida about 1 month ago

Hi Rebaekka,

The best solution is searching the nearest neighbor with remapnn:

cdo remapnn,lon=9.81_lat=46.83  infile outfile
Cheers, Uwe

RE: CDO: extract gridcell from netcdf file - Added by Rebekka Estermann about 1 month ago

Hi Uwe

Thanks for your help. I didn't know that one can also use remapnn in this way. Such an easy way compared to what I was trying with python. Does it first remap the whole file from rotated Pole (or whatever current grid) to regular lan lot coordinates and then select the given gridcell?

Best regards, Rebekka

RE: CDO: extract gridcell from netcdf file - Added by Uwe Schulzweida about 1 month ago

No remapping takes place with remapnn, it only searches for the nearest point. The search is based on geographical coordinates. Rotated coordinates are converted into geographical coordinates. With the CDO option -v, the source grid cell index and coordinates are also displayed:

cdo -v remapnn,lon=10_lat=57 infile outfile
...
cdo    remapnn: Target Point: lon=10/lat=57  Source Point: index=212060 lon=9.75/lat=57.25 distance=31.630km
...

    (1-3/3)