[Geotiff] RasterPixelIsArea versus RasterPixelIsPoint and listgeo -tfw

Pierre Soille Pierre.Soille at jrc.it
Mon Jan 16 13:42:20 EST 2006


Ed,

thanks for your kind email.

Grissom, Ed wrote:
> Pierre -
> This is confusing issue.   I want to be clear that I understand the 
> problem
> before I give advice.  Are we in agreement on the following points, or 
> am I
> misunderstanding ?
>
>
> #1 - TFW files should always be referenced to the "center-of-pixel", 
> similar
> to the PixelIsPoint reference in GeoTIFF.
>   
I also understand that TFW files should always be referenced to the 
"center-of-pixel".
> #2 - "Listgeo -tfw" must take into consideration the 
> GTRasterTypeGeoKey when
> it produces the tfw file.  In fact, it needs to add a half pixel shift 
> when
> GTRasterTypeGeoKey is PixelIsArea.
>   
This is what I thought it should do.  But it seems that  "Listgeo -tfw" 
ignores
GTRasterTypeGeoKey and always assume that PixelIsArea.
> #3 - You are seeing that it adds the half pixel shift in all cases, even
> when GTRasterTypeGeoKey is PixelIsPoint.
>   
Precisely.  I also looked at the C code of listgeo and do not see any 
reference to GTRasterTypeGeoKey
(it merely calls GTIFImageToPCS 
http://www.remotesensing.org/geotiff/api/geotiff_h.html#a35
to collect the coordinates of the tie points at fixed coordinate 0.5,0.5 
(i.e., centre of UL pixel):

...
   /*     * Compute the coefficients.
    */      
     x = 0.5;
     y = 0.5;

     if( !GTIFImageToPCS( gtif, &x, &y ) )
       return;
   adfCoeff[4] = x;
   adfCoeff[5] = y;
...

With my interpretation, the GTRasterTypeGeoKey should be used as follows
(where a_uint16 is a 16 bits unsigned integer):

...
    if (GTIFKeyGet(gtif,GTRasterTypeGeoKey, &a_uint16, 0, 1) != 1)
      a_uint16=RasterPixelIsArea;  /* default value if key not present */
    if  (a_uint16==RasterPixelIsArea){
       x = 0.5;          y = 0.5;
    }
    else if (a_uint16==RasterPixelIsPoint){
       x = 0.0;          y = 0.0;
    }
    else /* invalid Raster Space */
       return;
   if( !GTIFImageToPCS( gtif, &x, &y ) )
       return;
   adfCoeff[4] = x;
   adfCoeff[5] = y;
...

I attached a copy of the modified program (see mylistgeo.c).
>
>
> Is that a fair summary of the problem ?   Or is there more to it than 
> that ?
>   
No, this is a fair summary of the problem.

Pierre
>
> BTW:  As far as I can tell, your summary of the Point/Area issue is 
> correct.
>
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mylistgeo.c
Type: text/x-csrc
Size: 8750 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/geotiff/attachments/20060116/13a162bf/mylistgeo.bin


More information about the Geotiff mailing list