Project

General

Profile

Extracting whole layer as csv

Added by Lewis Dorling almost 3 years ago

Hi there,
I have a netcdf file that has one layer in it and I would like to extract all of the data for every grid point into a csv so I end up having for every grid point a lon, lat , value and have it stored in one csv file. I have only read about extracting timeseries from individual grid points so far so was wondering if it was possible to do this. I assume it is some combination of outputtab and remappn but I am unable to figure it out.

Cheers

Lewis


Replies (2)

RE: Extracting whole layer as csv - Added by Karin Meier-Fleischer almost 3 years ago

Hi Lewis,

it is easy to write the lat, lon, and values of data on a horizontal grid to a CSV file. See https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.14.6

For example:

cdo -outputtab,date,time,lat,lon,value -selname,tsurf,precip infile.nc > outfile.csv

outfile.csv:

#      date     time    lat    lon     name    value 
 2001-01-01 00:00:00 88.5722   -180    tsurf 242.3883 
 2001-01-01 00:00:00 88.5722 -178.125    tsurf 242.3512 
 2001-01-01 00:00:00 88.5722 -176.25    tsurf  242.234 
 2001-01-01 00:00:00 88.5722 -174.375    tsurf 242.2379 
 2001-01-01 00:00:00 88.5722 -172.5    tsurf 242.2672 
...
 2001-01-01 00:00:00 -88.5722 176.25    tsurf 236.0914 
 2001-01-01 00:00:00 -88.5722 178.125    tsurf 236.0719 
 2001-01-01 00:00:00 88.5722   -180   precip 1.843902e-06 
 2001-01-01 00:00:00 88.5722 -178.125   precip 1.843902e-06 
 2001-01-01 00:00:00 88.5722 -176.25   precip 1.843902e-06 
 2001-01-01 00:00:00 88.5722 -174.375   precip 1.844019e-06 
...
 2001-01-10 18:00:00 -88.5722 176.25   precip 9.212643e-06 
 2001-01-10 18:00:00 -88.5722 178.125   precip 9.223586e-06 

-Karin

    (1-2/2)