Ticket #796 (new defect)

Opened 3 years ago

Last modified 3 years ago

gdalinfo reports wrong values on GMT grid regisred grids

Reported by: jluis@ualg.pt Assigned to: warmerdam
Priority: high Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc: neteler

Description

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.

Attachments

lixo.grd (5.1 kB) - added by warmerdam on 03/14/05 00:52:04.
Sample Grid with grid registered convention.

Change History

03/14/05 00:52:04 changed by warmerdam

  • attachment lixo.grd added.

Sample Grid with grid registered convention.

04/15/05 15:53:08 changed by warmerdam

Supporting information.

...

Frank,
The point with GMT grids (but it doesn't restrict only to them) is that grids
can have both models. That's what GMT calls the grid and pixel registration.
The information on which model is used is contained in the GMT header
"Normal node registration used" for grid registration, or pixel-is-point,
and "Pixel node registration" (I think) in the other case.

Joaquim



Frank

GMT '.grd. files can be either 'line' or 'pixel' oriented
see the "node_offset" member in the GRD_HEADER struct

This is in "gmt_grd.h"
http://gmt.soest.hawaii.edu/gmt/doc/html/GMT_Docs/node144.html

HTH