[Qgis-user] Problem correctly reading Mapinfo TIF and TAB files into QGIS
David Addy
david_addy at lineone.net
Fri Dec 27 10:31:34 PST 2013
In this area of the UK, a number of local authorities use Mapinfo for their
Archaeology and Record Office services. This often involves reading
historical maps in order to compare with current conditions on the ground.
All such maps are calibrated within Mapinfo, and are usually in the form of
.TIF files accompanied by a .TAB file giving the georeferencing data. As
these departments are constantly under budgetary pressure there are many
applications where the use of QGIS could result in considerable cost
savings. However, it is necessary that existing maps should be easily read
by QGIS and correctly located,
without a cumbersome file conversion process.
An example of such maps is the 1880s First Series 1:2500 scale county
Ordnance Survey maps for Suffolk. At this scale it takes a large number of
tiles to cover a whole county. In a sample dozen of such maps around Bury St
Edmunds, only four were correctly located by QGIS. My mapping friend Nick
Hopton has kindly addressed this problem to the GDAL forum, using two sample
tiles, one of which works in QGIS and the other does not. The discussion on
this is reproduced below, and appears to come down to the size of the error
found by GDAL in its attempted transformation. AS this error seems to be
acceptable within Mapinfo, I do not quite understand why it cannot work
equally well within QGIS.
Obviously this must be a critical issue for all Mapinfo users who would like
to adopt QGIS, but find that this problem causes their evaluations to fail
at the first hurdle. Like myself, these users are not experts in the
technical details of map projections, nor the problems of making pre-1936
maps fit within today's UK Ordnance Survey OSGB36 Grid References.
However, we need to know whether anyone knows how to persuade QGIS/GDAL to
locate these tiles in the correct place please?
--------------------------------------------------
PROBLEM PREVIOUSLY ADDRESSED TO GDAL FORUM:
A friend, a relative newcomer to GIS, is having problems loading some of the
TIFs created with Mapinfo into QGIS. Each TIF has a TAB file and in some
cases the TAB file is interpreted correctly and in other cases the TAB file
is (apparently) not recognised.
I think this might be a problem with Gdal rather than a problem with QGIS.
Taking just two of the TIFs, the output from gdalinfo when run on
33044061.TIF indicates that things are working as they should. However, when
gdalinfo is run on 33044071.TIF the spatial data in its TAB file is not
recognised. See the listings below.
The strange thing is that all of the TIFs can successfully be converted from
TIF to GeoTIFF using gdalwarp. (But it is important to my friend that he
should be able to open Mapinfo raster images directly.)
Any ideas?
Regards,
Nick.
Contents of 33044061.TAB:
------------------------
!table
!version 300
!charset WindowsLatin1
Definition Table
File "33044061.tif"
Type "RASTER"
(582429,263569) (1,7594) Label "Pt 1",
(582372,265177) (1,0) Label "Pt 2",
(584784,265263) (11335,1) Label "Pt 3",
(584841,263655) (11335,7594) Label "Pt 4"
CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000,
-100000
Units "m"
Results of running gdalinfo on 33044061.TIF:
-------------------------------------------
nick at nick-6150M2MA:~/Desktop/tabstuff$ gdalinfo 33044061.TIF
Warning 1: TIFFFetchNormalTag:ASCII value for tag "ImageDescription"
contains null byte in value; value incorrectly truncated
during reading due to implementation limitations
Driver: GTiff/GeoTIFF
Files: 33044061.TIF
Size is 11335, 7594
Coordinate System is:
PROJCS["unnamed",
GEOGCS["unnamed",
DATUM["OSGB_1936",
SPHEROID["Airy 1930",6377563.396,299.3249646],
TOWGS84[375,-111,431,-0,-0,-0,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.9996012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
UNIT["Meter",1]]
GeoTransform =
582371.785312838, 0.2128106799708935, 0.007506419931892793
265177.0453393974, 0.007597130759524194, -0.2117600570261751
Metadata:
TIFFTAG_IMAGEDESCRIPTION=
TIFFTAG_XRESOLUTION=300
TIFFTAG_YRESOLUTION=300
TIFFTAG_MINSAMPLEVALUE=0
TIFFTAG_MAXSAMPLEVALUE=1
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Image Structure Metadata:
COMPRESSION=CCITTFAX4
INTERLEAVE=BAND
MINISWHITE=YES
Corner Coordinates:
Upper Left ( 582371.785, 265177.045) ( 0d40'19.83"E, 52d15'14.75"N)
Lower Left ( 582428.789, 263568.939) ( 0d40'19.71"E, 52d14'22.68"N)
Upper Right ( 584783.994, 265263.159) ( 0d42'27.09"E, 52d15'14.63"N)
Lower Right ( 584840.998, 263655.053) ( 0d42'26.92"E, 52d14'22.57"N)
Center ( 583606.392, 264416.049) ( 0d41'23.39"E, 52d14'48.66"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Palette
Image Structure Metadata:
NBITS=1
Color Table (RGB with 2 entries)
0: 255,255,255,255
1: 0,0,0,255
nick at nick-6150M2MA:~/Desktop/tabstuff$
Contents of 33044071.TAB:
------------------------
!table
!version 300
!charset WindowsLatin1
Definition Table
File "33044071.tif"
Type "RASTER"
(584841,263655) (1,7576) Label "Pt 1",
(584784,265263) (1,0) Label "Pt 2",
(587197,265349) (11335,1) Label "Pt 3",
(587254,263740) (11335,7576) Label "Pt 4"
CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 400000,
-100000
Units "m"
Results of running gdalinfo on 33044071.TIF:
-------------------------------------------
nick at nick-6150M2MA:~/Desktop/tabstuff$ gdalinfo 33044071.TIF
Warning 1: TIFFFetchNormalTag:ASCII value for tag "ImageDescription"
contains null byte in value; value incorrectly truncated
during reading due to implementation limitations
Driver: GTiff/GeoTIFF
Files: 33044071.TIF
Size is 11335, 7576
Coordinate System is `'
GCP Projection =
PROJCS["unnamed",
GEOGCS["unnamed",
DATUM["OSGB_1936",
SPHEROID["Airy 1930",6377563.396,299.3249646],
TOWGS84[375,-111,431,-0,-0,-0,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.9996012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
UNIT["Meter",1]]
GCP[ 0]: Id=Pt 1, Info=
(1,7576) -> (584841,263655,0)
GCP[ 1]: Id=Pt 2, Info=
(1,0) -> (584784,265263,0)
GCP[ 2]: Id=Pt 3, Info=
(11335,1) -> (587197,265349,0)
GCP[ 3]: Id=Pt 4, Info=
(11335,7576) -> (587254,263740,0)
Metadata:
TIFFTAG_IMAGEDESCRIPTION=
TIFFTAG_XRESOLUTION=300
TIFFTAG_YRESOLUTION=300
TIFFTAG_MINSAMPLEVALUE=0
TIFFTAG_MAXSAMPLEVALUE=1
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Image Structure Metadata:
COMPRESSION=CCITTFAX4
INTERLEAVE=BAND
MINISWHITE=YES
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 7576.0)
Upper Right (11335.0, 0.0)
Lower Right (11335.0, 7576.0)
Center ( 5667.5, 3788.0)
Band 1 Block=512x512 Type=Byte, ColorInterp=Palette
Image Structure Metadata:
NBITS=1
Color Table (RGB with 2 entries)
0: 255,255,255,255
1: 0,0,0,255
-------------------------------------------------------------------
FRANK WARMERDAM REPLIED:
Nick,
I haven't tried the .TAB files locally, but I see they are both resulting in
georeferencing info. The one is expressed as a
geotransform with rotation and shear while the other is expressed as ground
control points.
I believe that the .TAB reader attempts to compute a geotransform from the
points in the TAB and if it can do so with minimal
error then that is what is returned - a solution easier to utilize in QGIS
and other applications.
If the control points do not represent a clean affine transformation for the
image then it falls back to returning them as
ground control points which relatively few applications can utilize
directly.
One "solution" is to run gdalwarp to transform the image that isn't
currently working so well into a north up affine
transformation style image.
eg.
gdalwarp 33044071.TIF 33044071_northup.TIF
This warp will be done using the control points (ironically also using a
best fit first order polynomial).
The code responsible for the decision is this from gdal/gcore/gdal_misc.cpp:
/* -------------------------------------------------------------------- */
/* Try to convert the GCPs into a geotransform definition, if */
/* possible. Otherwise we will need to use them as GCPs. */
/* -------------------------------------------------------------------- */
if( !GDALGCPsToGeoTransform( nCoordinateCount, asGCPs, padfGeoTransform,
FALSE ) )
{
if (pnGCPCount && ppasGCPs)
{
CPLDebug( "GDAL",
"GDALLoadTabFile(%s) found file, wasn't able to derive a\n"
"first order geotransform. Using points as GCPs.",
pszFilename );
*ppasGCPs = (GDAL_GCP *)
CPLCalloc( sizeof(GDAL_GCP),nCoordinateCount );
memcpy( *ppasGCPs, asGCPs, sizeof(GDAL_GCP) * nCoordinateCount
);
*pnGCPCount = nCoordinateCount;
}
}
else
{
GDALDeinitGCPs( nCoordinateCount, asGCPs );
}
I suspect if you change the FALSE to TRUE in the arguments to
GDALGCPsToGeoTransform() you wlil always get an affine
transform even when it is not a very good fit.
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Problem-correctly-reading-Mapinfo-TIF-and-TAB-files-into-QGIS-tp5095647.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.
More information about the Qgis-user
mailing list