Bug #543

grdreformat: same grid different output

Added by Eduardo over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:2014-04-16
Priority:NormalDue date:
Assignee:-% Done:

90%

Category:-
Target version:Candidate for next bugfix release
Affected version:5.x-svn Platform:

Description

grdreformat srtm_22_21.asc=gd g_a.grd -fg -V
grdreformat srtm_22_21.asc=ei g_b.grd -fg -V

then

grdinfo g_a.grd
g_a.grd: Title: Produced by grdreformat
g_a.grd: Command: grdreformat srtm_22_21.asc=gd g_a.grd -fg -V
g_a.grd: Remark:
g_a.grd: Gridline node registration used [Geographic grid]
g_a.grd: Grid file format: nf = GMT netCDF format (32-bit float), COARDS, CF-1.5
g_a.grd: x_min: 285.000000145 x_max: 290.000000145 x_inc: 0.000833333333333 name: longitude [degrees_east] nx: 6001
g_a.grd: y_min: -44.9999997579 y_max: -39.9999997579 y_inc: 0.000833333333333 name: latitude [degrees_north] ny: 6001
g_a.grd: z_min: -79 z_max: 3332 name: z
g_a.grd: scale_factor: 1 add_offset: 0
g_a.grd: format: netCDF-4 chunk_size: 131,131 shuffle: on deflation_level: 3

grdinfo g_b.grd
g_b.grd: Title: Produced by grdreformat
g_b.grd: Command: grdreformat srtm_22_21.asc=ei g_b.grd -fg -V
g_b.grd: Remark:
g_b.grd: Pixel node registration used [Geographic grid]
g_b.grd: Grid file format: nf = GMT netCDF format (32-bit float), COARDS, CF-1.5
g_b.grd: x_min: 284.999583479 x_max: 290.000416812 x_inc: 0.000833333333333 name: longitude [degrees_east] nx: 6001
g_b.grd: y_min: -45.0004164245 y_max: -39.9995830912 y_inc: 0.000833333333333 name: latitude [degrees_north] ny: 6001
g_b.grd: z_min: -79 z_max: 3332 name: z
g_b.grd: scale_factor: 1 add_offset: 0
g_b.grd: format: netCDF-4 chunk_size: 131,131 shuffle: on deflation_level: 3

History

#1 Updated by Paul over 3 years ago

  • Status changed from New to Feedback

Are the input files asciii (.asc)? I.e., ESRI exchange format? If so no need for =gd.

#2 Updated by Paul over 3 years ago

Sorry, early here and clearly not enough coffee. Could you post the header part of the asc file?

#3 Updated by Joaquim over 3 years ago

Honestly, I don't see a way out of this. If for instance

grdreformat srtm_22_21.asc=ei g_b.grd -fg -V

would produce a grid registered grid and we had maintained the GDAL practice of reporting everything as pixel registered, than we would found ourselves in exactly the same situation (but reversed in terms of what is reported as grid and pixel reg).

The GeoTiff case, however, is different as it reports in it's own way if grid is pixel or grid reg. Though this is apparently often not respected we must pay attention to it.

#4 Updated by Eduardo over 3 years ago

head -6 srtm_22_21.asc 
ncols         6001
nrows         6001
xllcorner     -75.00041652139
yllcorner     -45.000416424533
cellsize      0.00083333333333333
NODATA_value  -9999

#5 Updated by Paul over 3 years ago

Right, so they screwed up and packaged a gridline-registered file as a pixel grid. It should have been

ncols 6001
nrows 6001
xllcorner -75
yllcorner -45
cellsize 0.00083333333333333

They may have done this because some other software could not handle the concept of gridline-registation. We cannot convince them of doing the right thing, so just grdedit first.

#6 Updated by Joaquim over 3 years ago

No, in this case they are right. The 'corner' means pixel registration (grid is 'center'). See

http://resources.esri.com/help/9.3/arcgisengine/java/GP_ToolRef/spatial_analyst_tools/esri_ascii_raster_format.htm

The crash for the other case is due to a attempt to free a no-longer valid memory address that probably should have been set to NULL before ... or some other reason. Had no time to debug further and now I have to go.

#7 Updated by Paul over 3 years ago

Right, but since the corner is 1/2 pixel outside then the center is at the gridline so it is in effect a gridline-registered file; it is just reported with an -R that is adjusted by that 1/2 pixel.

#8 Updated by Joaquim over 3 years ago

We know that, which in fact is the source of all their errors but to have grdreformat give the right result one needs to change the header to

ncols 6001
nrows 6001
xllcenter -75
yllcenter -45
cellsize 0.00083333333333333

#9 Updated by Paul over 3 years ago

Yes, we agree. Sorry, mean to change to center as well.

#10 Updated by Joaquim over 3 years ago

  • Status changed from Feedback to Resolved

Because this issue shares a lot with #541, I posting the same update

On r13222 and r13226 (5.2 branch) I implemented the capability of reading and writing the GeoTiff key(s) that inform whether a grid is pixel or grid registered. This means we now can write pixel and grid registered and same for reading. There will be still an ambiguous case for files that have not set the AREA_OR_POINT key. In this case, the old default (grids are always grid reg) is maintained.
As far as I can tell, this the most we can do to address this issue and (#541). So I'm declaring this solved ... till next round

#11 Updated by Joaquim over 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 90
  • Platform deleted (Linux)

Also available in: Atom PDF