Project

General

Profile

Import text file and convert from rotated lat lon grid to geographic co-ordinate system

Added by Rachel Carr about 11 years ago

Dear All,

I am new to CDO and would appreciate any help you could give me with the following problem.

I am using CDO with Cygwin. I have a set of data which give a value for ice melt at a series of grid points and are in a text file (Melt.txt). The data are in a rotated lat lon grid and I want to convert them to a geographical co-ordinate system so that I can import the data into GIS software as a netcdf of ascii file. I have read the forum posts for rotated grids and importing ascii data, but am struggling to do both.

I tried to use the following to import the data and convert to netcdf:

cdo –f nc input,Descrip.text ofile.nc < Melt.txt

Contents of Describ.txt:
gridtype = lonlat
gridsize = 95472
xname = rlon
xlongname = longitude in rotated pole grid
xunits = degrees
yname = rlat
ylongname = latitude in rotated pole grid
yunits = degrees
xsize = 306
ysize = 312
xnpole = -37.5
ynpole = 72
xfirst = -11.35
xinc = 0.1
yfirst = -15.80
yinc = 0.1

However, when I enter the command, I get the following message, which looked like it would continue until 95472:

cdo input: Enter all 95472 elements of record 1!
cdo input: Enter all 95472 elements of record 2!

Could I ask if this this the right approach to import the data and set the rotated grid? If so, could I ask how to do the import correctly and avoid this message?

In addition, am I right in thinking I need to do the following to transform the data to geog lat/lon:
cdo setgrid, newdescrip.txt ofile.nc output_file.nc
Where newdescrip.txt is:
gridtype = lonlat
gridsize = 95472
xname = rlon
xlongname = longitude
xunits = degrees
yname = rlat
ylongname = latitude
yunits = degrees
xsize = 306
ysize = 312
xnpole = 0
ynpole = 90
xinc = 0.1
yinc = 0.1

Many thanks in advance for your help.

Rachel


Replies (4)

RE: Import text file and convert from rotated lat lon grid to geographic co-ordinate system - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

Could you please upload a sample of your input ASCII file? Also, the following thread may help you: https://code.zmaw.de/boards/1/topics/329#message-330

Cheers,
J

RE: Import text file and convert from rotated lat lon grid to geographic co-ordinate system - Added by Rachel Carr about 11 years ago

Hi Jaison,

I have attached the first few lines of the data. The data are in the following form: lon, lat, 252 values of melt (one for each month between Jan 1990 and Dec 2010). This information is available for each point in a 306 by 312 grid, which covers Greenland and the surrounding area.

Thanks for the link to the post. Am I correct in thinking that you need to add all of the x / y values to the grid description file? I looked at this before, but did not consider it because I have ~ 95,000 grid points. That said, I created a set of files for each month/year (e.g. Melt_sample_199008.txt), so could do something similar to get the data into the form described in the post.

Many thanks,

Rachel

RE: Import text file and convert from rotated lat lon grid to geographic co-ordinate system - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

That said, I created a set of files for each month/year (e.g. Melt_sample_199008.txt), so could do something similar to get the data into the form described in the post.

I think you don't need to do that. You just need to provide a column/row of all melt values (all time steps). Here is a test case where I've created two sets of random data (for two time steps):

cdo -outputtab,value -random,r306x312 > data.dat

cdo -outputtab,value -random,r306x312 >> data.dat

then I used your "Descrip.text" grid description to create the NetCDF

cdo -f nc input,Descrip.text ofile.nc < data.dat

Checking "cdo sinfov ofile.nc" shows there are two time steps of the given data as wxpected; so I guess this should work for you as well.

You could use awk '{print $3}' to clip the 3rd column/melt data from your file since you don't need the lon-lat in this case.

Anyway, hope this helps!

Cheers,
J.

RE: Import text file and convert from rotated lat lon grid to geographic co-ordinate system - Added by Rachel Carr about 11 years ago

Thanks Jaison,

That was my thought as well, but after checking the in ArcGIS, I'm not sure the 'rotated pole' part of the grid description is working properly: if I change xnpole or ynpole considerably in the original description file (Descrip.txt) it does not change the output lat / lon values. Furthermore, the output lat/llon values (which should be in geog lat/lon) are very similar to the input values (which are in the rotated grid system). Perhaps I am wrong, but I would expect the lat/lon values to be considerably different, so I assume the the 'rotated' part of the original grid description is not being applied properly. Any ideas would be gratefully recieved.

Many thanks,

Rachel

    (1-4/4)