Project

General

Profile

extract values of points (lat/long) from netCDF files

Added by Heidi Sevestre about 12 years ago

Dear CDO users,

I am very new to CDO, and I'm trying to find a way to extract the values of 1000+ points of known coordinates (lat/long) from my netCDF files. My netCDF files are projected on a curvilinear grid. Is it possible to extract the values of all my points for each time series (hence creating a table with the following headers: point - lat - long - time - value) for each time unit?
Hope you'll help with to solve my problem :-) Any help would be very much appreciated.

Best regards,

Heidi


Replies (6)

RE: extract values of points (lat/long) from netCDF files - Added by Jaison-Thomas Ambadan about 12 years ago

Hi,

The operator "outputtab" (it's an experimental undocumented operator) may help you. please have a look at the following thread (last post by Uwe Schulzweida)

https://code.zmaw.de/boards/1/topics/1315#message-1320

Cheers,
J.

RE: extract values of points (lat/long) from netCDF files - Added by Khumo Monaka about 4 years ago

Greetings, Can you kindly assist? I am new also and i want to extract data for a point (Lat/Lon). I am comparing model data with station data, I am using Regcm4.7 to assess rainfall variability using model and station data for period 1981/2010.

regards

RE: extract values of points (lat/long) from netCDF files - Added by Karin Meier-Fleischer about 4 years ago

Hi Heidi,

you can extract the data for a single point using remapnn and outputtab operators.

For example, you want to extract data from a netCDF file close to the point
lon=9.0/lat=54.0 deg. then you have to find the nearest point to it and write the
data to an ASCII file:

cdo -outputtab,date,lon,lat,value -remapnn,"lon=9.0_lat=54.0" infile.nc > output.csv

-Karin

RE: extract values of points (lat/long) from netCDF files - Added by Malcolm Mistry over 3 years ago

Dear All,
I stumbled upon this old question and was actually looking to do the same. However I have multiple input points in a .csv file (Did not want to open a new thread as the question is related to this one). I would like to extract the variable from the netcdf file in the same way as above (i.e. writing the output to a single .csv file). I suppose this will require a bash script (perhaps a for loop)? The output .csv file should ideally contain Date, Location_Name, Lat, Lon, Value; wherein the Location_Name, comes from the input .csv, and other columns from the netcdf.

I have across a solution in python but it is painstakingly slow for a high-resolution netcdf file with daily data spanning 30-40 years. My input .csv contains about 2000 point locations. Am open to suggestions in Fortran and C (with netcdf libraries) as well, but I suppose CDO should be able to do this as well in bash.

Thanks and regards
Malcolm

RE: extract values of points (lat/long) from netCDF files - Added by Karin Meier-Fleischer over 3 years ago

Hi Malcom,

starting from the CDOs point of view, it can be done with a bash script, of course. The Location_Name then can be used as a file name for example. You can do some test to better understand what CDO will return using the above example call.

-Karin

RE: extract values of points (lat/long) from netCDF files - Added by Malcolm Mistry over 3 years ago

Hello Karin,
Many thanks. Should I find an optimum solution using CDO, I will post it here. Thank you for your earlier response for the single point location which was very useful!
Rgds
Malcolm

    (1-6/6)