[Gdal-dev] Gdal and NetCDF...
Emilio Mayorga
emiliomayorga at gmail.com
Thu Mar 23 15:42:28 EST 2006
---------- Forwarded message ----------
From: Daniel Victoria <daniel.victoria at gmail.com>
Date: Mar 23, 2006 11:57 AM
Subject: Re: Gdal and NetCDF...
To: Emilio Mayorga <emiliomayorga at gmail.com>
Hi Emilio,
I think I solved it. The nc file stores the cell centers so, when GDAL
calculates the resolution it divides the distance between the cell
centers by the number of cells. This leaves half of the first and last
cell outside. Something like this
|---X---|- - - - - - - |---X---|
It will calculate from X to X.
But reading some messages on the list I saw that there is a - a_ullr
switch in GDAL. I used that to force the correct dimensions and now I
can convert NetCDF to GTiff with no problem.
One thing tough. I could not get GDAL to compile with NetCDF support
so I'm using the GDAL supplied with FWTools
Cheers
Daniel
On 3/23/06, Emilio Mayorga <emiliomayorga at gmail.com> wrote:
> Oi Daniel!
>
> Good to see you here. I don't have an answer for you (I've never used
> the GDAL bindings for netcdf, although I do have a lot of experience
> with netcdf), but I found this recent thread in the FWTools list that
> refers to exactly the same problem. The poster was using OpenEV to
> access a netcdf file, but OpenEV must use the same GDAL code to access
> netcdf files.
> http://lists.maptools.org/pipermail/fwtools/2006-February/000279.html
>
> Maybe Frank has looked into the problem more closely, recently?
>
> Good luck,
>
> -Emilio
>
>
> > From: "Daniel Victoria" <daniel.victoria at gmail.com>
> > To: gdal-dev at lists.maptools.org
> > Date: Tue, 21 Mar 2006 15:10:24 -0300
> > Subject: [Gdal-dev] Gdal and NetCDF...
> > Hi all,
> >
> > I have a very simple python program that subsets and converts the CRU
> > 0.5 degrees time series data in a NetCDF format following COARDS
> > conventions - hopefully -
> >
> > Now, I want to convert this NetCDF to TIFF using gdal and import it to
> > GRASS. When I ask my program to subset the CRU data from 10 to 30
> > degrees latitude it will get 41 cells from 10.25 to 30.25 (I'm using
> > cell centers). This means that the data spans from 10 (south edge) to
> > 30.5 (north edge), with 41 cells, which equals 0.5 degrees resolution.
> >
> > Now, when I do a gdalinfo on the NetCDF file I get a resolution of
> > 0.4878 (equals 20 degrees / 41 cells).
> >
> > Could someone point me to what I'm doing wrong? Is this a feature/bug?
> > I'm using GDAL provided by the FWTools-linux-1.0.0a7
> >
> > I'm attaching the information on the NetCDF file (ncdump and gdalinfo)
> >
> > Thanks a bunch
> > Daniel
> >
> > ----- ncdump output -----
> >
> > netcdf saida {
> > dimensions:
> > X = 41 ;
> > Y = 41 ;
> > T = 12 ;
> > variables:
> > double Y(Y) ;
> > Y:long_name = "Latitude" ;
> > Y:units = "degrees_north" ;
> > double X(X) ;
> > X:long_name = "Longitude" ;
> > X:units = "degrees_east" ;
> > short T(T) ;
> > T:long_name = "Months" ;
> > T:units = "months since 1981-01-01" ;
> > short pre(T, Y, X) ;
> > pre:long_name = "Precipitation" ;
> > pre:units = "mm" ;
> > pre:scale_factor = 0.1 ;
> > pre:missing_value = -9990 ;
> >
> > // global attributes:
> > :Conventions = "COARDS" ;
> > :history = "Tyndall Centre grim file created on 13.01.2004 at 14
> > :28 by Dr. Tim Mitchel" ;
> > :production = "CRU TS 2.1 converted to NetCDF by Daniel" ;
> > data:
> >
> > Y = 30.25, 29.75, 29.25, 28.75, 28.25, 27.75, 27.25, 26.75, 26.25, 25.75,
> > 25.25, 24.75, 24.25, 23.75, 23.25, 22.75, 22.25, 21.75, 21.25, 20.75,
> > 20.25, 19.75, 19.25, 18.75, 18.25, 17.75, 17.25, 16.75, 16.25, 15.75,
> > 15.25, 14.75, 14.25, 13.75, 13.25, 12.75, 12.25, 11.75, 11.25, 10.75,
> > 10.25 ;
> >
> > X = 75.25, 75.75, 76.25, 76.75, 77.25, 77.75, 78.25, 78.75, 79.25, 79.75,
> > 80.25, 80.75, 81.25, 81.75, 82.25, 82.75, 83.25, 83.75, 84.25, 84.75,
> > 85.25, 85.75, 86.25, 86.75, 87.25, 87.75, 88.25, 88.75, 89.25, 89.75,
> > 90.25, 90.75, 91.25, 91.75, 92.25, 92.75, 93.25, 93.75, 94.25, 94.75,
> > 95.25 ;
> >
> > T = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ;
> >
> > <snip> file values...
> >
> >
> > ------ GDAL info output --------
> > Driver: netCDF/network Common Data Format
> > Size is 41, 41
> > Coordinate System is `'
> > Origin = (75.250000,30.250000)
> > Pixel Size = (0.48780488,-0.48780488)
> > Metadata:
> > NC_GLOBAL#Conventions=COARDS
> > NC_GLOBAL#history=Tyndall Centre grim file created on 13.01.2004 at 14:28 by D
> > r. Tim Mitchel
> > NC_GLOBAL#production=CRU TS 2.1 converted to NetCDF by Daniel
> > pre#long_name=Precipitation
> > pre#units=mm
> > pre#scale_factor=0.1
> > pre#missing_value=-9990
> > X#long_name=Longitude
> > X#units=degrees_east
> > Y#long_name=Latitude
> > Y#units=degrees_north
> > T#long_name=Months
> > T#units=months since 1981-01-01
> > Corner Coordinates:
> > Upper Left ( 75.2500000, 30.2500000)
> > Lower Left ( 75.2500000, 10.2500000)
> > Upper Right ( 95.2500000, 30.2500000)
> > Lower Right ( 95.2500000, 10.2500000)
> > Center ( 85.2500000, 20.2500000)
> >
> > <snip> band information...
>
More information about the Gdal-dev
mailing list