Changes between Version 4 and Version 5 of Ticket #1462


Ignore:
Timestamp:
Apr 8, 2007, 2:00:19 PM (17 years ago)
Author:
Mateusz Łoskot
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1462 – Description

    v4 v5  
    1 {{{
    2 The out-by-1 problem  with the GMT driver was again recently reported. It appears that this is quite an old problem as the initial postings to the GDAL community were made in 2005. The first appears to be  #796 on 13 March 2004 by jluis.  The second was on 15 April 2005  also by jluis. Another on November 18 2005, Rich Signal  reports the same problem.
     1The out-by-1 problem  with the GMT driver was again recently reported. It appears that this is quite an old problem as the initial postings to the GDAL community were made in 2005.
    32
    4 We have discussed the problem in the GMT community.  GMT is able to support grid referenced data AND pixel registered data. We have routines to transfer between these if there is a need to do so. The use of grid referenced data in GMT is mainly historical so resampling can be very lossy especially at scales near the Nyquist frequency of the grid. Thus the solution to the problem may be to output the region of interest as a pixel registered grid and to make the header information consistent with this option. What I am attempting to say here is that the GMT community is not locked into a grid reference model when the underlying data set is pixel registered. grdinfo in GMT will return the type of grid that is being used so the onus can be placed on the GMT community to understand the imported grid.
     3The first appears to be  #796 on 13 March 2004 by jluis.
     4The second was on 15 April 2005  also by jluis.
     5Another on November 18 2005, Rich Signal  reports the same problem.
    56
     7We have discussed the problem in the GMT community. GMT is able to support grid referenced data AND pixel registered data. We have routines to transfer between these if there is a need to do so.
    68
     9The use of grid referenced data in GMT is mainly historical so resampling can be very lossy especially at scales near the Nyquist frequency of the grid. Thus the solution to the problem may be to output the region of interest as a pixel registered grid and to make the header information consistent with this option.
     10
     11What I am attempting to say here is that the GMT community is not locked into a grid reference model when the underlying data set is pixel registered. grdinfo in GMT will return the type of grid that is being used so the onus can be placed on the GMT community to understand the imported grid.
    712
    813For these tests I cut from the USGS Seamless server the following region using the direct entry of the region of interest.
    914
     15{{{
    1016                                    |                                          |
    1117                                    |                                          |
     
    1925                            113 59 00.000                     115 01 00.000
    2026                         (113.98333333)                     (115.01666667)
    21 
     27}}}
    2228
    2329Using gdalinfo on the returned file  we see the following
     30
     31{{{
    2432[peterm@currawong 16733119]$ gdalinfo w001001.adf
    2533Driver: AIG/Arc/Info Binary Grid
     
    5058 Min=-7.000 Max=2371.000
    5159 NoData Value=-3.40282346638529e+38
     60}}}
    5261
    53 Note  that the subtle difference between the definition of the origin and the Upper Left corner definition is a numeric
    54 problem. There are indeed 1240 cells, (columns) from 113.9833333 to 115.0166667 similarly there are 1240 cells, (rows), from
     62Note that the subtle difference between the definition of the origin and the Upper Left corner definition is a numeric problem.
     63
     64There are indeed 1240 cells, (columns) from 113.9833333 to 115.0166667 similarly there are 1240 cells, (rows), from
    55653.9833333 to 5.0166667. These cells are 0.000833333333300 degrees which is equivalent to 3 arc seconds.
    5666This indicates that we do indeed have a pixel registered data set.
    5767
    58 Running the  routine gdal_translate [peterm@currawong 16733119]$ gdal_translate w001001.adf -of GMT w001001.gmt
     68Running the routine gdal_translate
     69
     70{{{
     71[peterm@currawong 16733119]$ gdal_translate w001001.adf -of GMT w001001.gmt
    5972Input file size is 1240, 1240
    60 [peterm@currawong 16733119]$
     73}}}
     74
    6175says that the input file size was  1240-by-1240
    6276Now we can get information on the output file by two methods:
    63  1. using gdalinfo
    6477
     78'''1. using gdalinfo'''
     79
     80{{{
    6581   [peterm@currawong 16733119]$ gdalinfo w001001.gmt
    6682Driver: GMT/GMT NetCDF Grid Format
     
    7692Center      ( 114.5000000,   4.5000000)
    7793Band 1 Block=1240x1 Type=Float32, ColorInterp=Undefined
     94}}}
    7895
    7996Notice that the cell size is no longer 0.00083333333 but .000834005918718.
    80 This change in size is coupled with changes in the origin which is now
    81 (113.982916325079145,5.017083670745943) which is
     97
     98This change in size is coupled with changes in the origin which is now (113.982916325079145,5.017083670745943) which is
    8299113 58 58.498    5 01 01.5012
    83 The lower right corner is ( 115.0170837,   3.9829163)  or 115 01 01.501,  03 58 58.49868
    84 The longitude difference of  1.034167 corresponds to 1241 cells when the size is 0.00083333
     100The lower right corner is
     101( 115.0170837,   3.9829163)
     102or
     103115 01 01.501,  03 58 58.49868
     104The longitude difference of 1.034167 corresponds to 1241 cells when the size is 0.00083333
    85105or                                                                                  1240 cells when the size is 0.00083400591871
    86106A similar computation results for latitude.
     
    88108This is a bastard system as it appears that the origins have been adjusted to move from pixel to grid registration but that is all. To make things consistent the cell width has be modified.
    89109
    90 2. getting information with grdinfo a GMT command.
     110'''2. getting information with grdinfo a GMT command.'''
     111
     112{{{
    91113[peterm@currawong 16733119]$ grdinfo w001001.gmt
    92114w001001.gmt: Title:
     
    99121w001001.gmt: z_min: -7.000000e+00 z_max: 2.371000e+03 name: meters
    100122w001001.gmt: scale_factor: 1.000000e+00 add_offset: 0.000000e+00
     123}}}
    101124
    102125Here the grid size is 0.0008333 and the number of grid cells is 1240-by-1240.
     
    105128I am a little puzzled that these two info routines return different information. I presume that this is because they interrogated different parts of the header.
    106129
    107 
    108130It is hypothesised that the GDAL routines have failed to output the additional row and column that result from a conversion from a pixel registered grid to a grid reference grid. The correct process of transforming between these two grid types involves some form of resampling which is why the initial grid should be oversized if the process is pixed to reference grid.
    109 }}}