[gdal-dev] effects of differences in .tgf and .tab files on Tiff imports

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Fri Jan 24 01:46:48 PST 2014


To Tim Southern -

GDAL uses several different methods find information to georeference 
tiff files (Disclaimer: I'm not at all familiar with THE GDAL codebase 
and just had a brief look at the relevant c++ files):

 1. GDAL look for georeference information embedded in the tiff file and
    will use it to georeference the file.
 2. If no 1 fails it will look for a corresponding  .twf or similar
    named files and read 6 parameters from it to establish affine
    transformations to/from the "pixel" coordinate system and the
    "world" coordinate system.
 3. If no 2 fails it will look for a corresponding .tab file, read the
    ground control points (GCP)  and establish the transformations using
    these GCP's.

So, if your tiff file doesn't contain embedded information, GDAL wil use 
the twf file.

However: (And now I'm making some big assumptions):

  * I assume the size of the tiff file is 4724 x 4724
  * I assume the upper leftmost  _egde_ of the image is at position
    459000,181000 in the coordinate system.
  * I assume the lower rightmost _edge_ of the image is at position
    460000,180000 in the coordinate system, making the tiff file  1000 x
    1000 m in size in "world" coordinates

This will make the pixel height and width approx. 0.2116850127 meters, 
not 0.21168 as implied in the twf file.

*If* my assumptions are correct both the tfw and the tab-file contains 
incorrect parameters. The twf should look like this:

0.2116850127
0.0
0.0
-0.2116850127
459000.10584250635
180999.89415749365

The translation parameters (last 2 lines) is defined from the center of 
the pixel, not the edge

The tab file should look like this:

!table
!version 300
!charset WindowsLatin1
Definition Table
   File "02SU5980.tif"
   Type "RASTER"
   (459000.10584250635, 180999.89415749365) (0,0) Label "Pt 1",
   (459999.89415749365, 180999.89415749365) (4723,0) Label "Pt 2",
   (459999.89415749365, 180000.10584250635) (4723,4723) Label "Pt 3",
   (459000.10584250635, 180000.10584250635) (0,4723) Label "Pt 4"
   CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, 
-100000

The number of decimals might be a slight "overkill" :-)
(The tab file doesn't contains any kind "rectangle" definitions; the 
GCP's could be placed anywhere in the image. But normally they are 
defined for the corners of the image)

Regards
Bo Victor Thomsen
Aestas-GIS
Denmark

Den 20-01-2014 11:02, Tim Southern skrev:
> Dear Sir/Madame,
>
> I have recently downloaded a number of historic analogue maps which 
> have associated .twf and .tab files.  I notice that both these text 
> files are required by GDAL for geo-referencing according to the 
> information given on the appropriate web page for inputing 
> tiff/geotiff files.
>
> In this particular case the two files are not compatible with each 
> telling the system slightly different things.  I have copied the 
> contents below.  How will GDAL handle this situation?
>
> Thanks
>
> Tim Southern
>
> .tab file
>
> !table
> !version 300
> !charset WindowsLatin1
>
> Definition Table
>   File "02SU5980.tif"
>   Type "RASTER"
>   (459000, 181001) (0,0) Label "Pt 1",
>   (459999, 181001) (4723,0) Label "Pt 2",
>   (459999, 180001) (4723,4723) Label "Pt 3",
>   (459000,180001) (0,4723) Label "Pt 4"
>   CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000, 
> -100000
>
>
> and the .twf file is
>
> 0.21168000
> 0.0000
> 0.0000
> -0.21168000
> 459000.00000000
> 181000.00000000
>
> The .tab file gives coordinates for the pixel 0, 0 as 459000, 
> 181001 whereas the .twf file defines the same pixel as 459000, 181000.
> The .tab file gives coordinates for the pixel 4723,0 as 459999, 
> 181001 whereas the .twf gives the same pixels as 459999.76464, 181000.
> The .tab file gives coordinates for the pixel 4723, 4723 as 459999, 
> 180001 whereas .twf file gives same point as 459999.76464, 180000.23536
> The .tab file gives coordinates for the pixel 0, 4723 as 459000, 
> 180001 whereas .twf file gives same point as 459000, 180000.23536
>
> Another obvious difference is .tab file define a rectangle 999 by 
> 1000 metres whereas the .twf file defines a square 999.76464 by 
> 999.76464 metres.
>
>
>
> Tim Southern
> 17, Park Close,
> Sonning Common,
> Oxfordshire
> RG4 9RY
>
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140124/aea1312f/attachment.html>


More information about the gdal-dev mailing list