[Gdal-dev] gdalinfo and GMT grids

jluis at ualg.pt jluis at ualg.pt
Sun Mar 13 17:23:01 EST 2005


Hi,

Regarding GMT grids, gdalinfo gives uncorrect results.

This creates a grid with a grid step of 1
grdmath -R-15/15/-15/15 -I1 = lixo.grd

Runing grdinfo tells us
lixo.grd: Title:
lixo.grd: Command: grdmath -R-15/15/-15/15 -I1 = lixo.grd
lixo.grd: Remark:
lixo.grd: Normal node registration used
lixo.grd: grdfile format # 0
lixo.grd: x_min: -15 x_max: 15 x_inc: 1 units: user_x_unit nx: 31
lixo.grd: y_min: -15 y_max: 15 y_inc: 1 units: user_y_unit ny: 31
lixo.grd: z_min: 0 z_max: 0 units: user_z_unit
lixo.grd: scale_factor: 1 add_offset: 0

However
gdalinfo says:

Driver: GMT/GMT NetCDF Grid Format
Size is 31, 31
Coordinate System is `'
Origin = (-15.000000,15.000000)
Pixel Size = (0.96774194,-0.96774194)
Corner Coordinates:
Upper Left  ( -15.0000000,  15.0000000)
Lower Left  ( -15.0000000, -15.0000000)
Upper Right (  15.0000000,  15.0000000)
Lower Right (  15.0000000, -15.0000000)
Center      (   0.0000000,   0.0000000)

Note how the "Pixel Size" differs from 1

But, if we generate the GMT grid this way (a "pixel registerd" grid)
grdmath -R-15/15/-15/15 -I1 -F = lixo.grd
than grdinfo reports

lixo.grd: Title:
lixo.grd: Command: grdmath -R-15/15/-15/15 -I1 -F = lixo.grd
lixo.grd: Remark:
lixo.grd: Pixel node registration used
lixo.grd: grdfile format # 0
lixo.grd: x_min: -15 x_max: 15 x_inc: 1 units: user_x_unit nx: 30
lixo.grd: y_min: -15 y_max: 15 y_inc: 1 units: user_y_unit ny: 30
lixo.grd: z_min: 0 z_max: 0 units: user_z_unit
lixo.grd: scale_factor: 1 add_offset: 0

and gdalinfo now gives the correct pixel size.

Driver: GMT/GMT NetCDF Grid Format
Size is 30, 30
Coordinate System is `'
Origin = (-15.000000,15.000000)
Pixel Size = (1.00000000,-1.00000000)
Corner Coordinates:
Upper Left  ( -15.0000000,  15.0000000)
Lower Left  ( -15.0000000, -15.0000000)
Upper Right (  15.0000000,  15.0000000)
Lower Right (  15.0000000, -15.0000000)
Center      (   0.0000000,   0.0000000)


What seams to be happening is that gdal assumes all grids have a "pixel
registration". And that is not allways true, in what ragards GMT grids, but it
is also
not true for example with GTOPO30 (or SRTM30) and SRTM 1-arc-sec or SRTM
3-arc-sec. The first are pixel registerd, but the seconds are grid registerd.

See http://gmt.soest.hawaii.edu/gmt/doc/html/GMT_Docs/node145.html
for a explanation on the difference between "grid" and "pixel" registrations.

Joaquim Luis




More information about the Gdal-dev mailing list