[gdal-dev] TIFs with TABs problem

Nick Hopton nhopton at gmail.com
Wed May 29 01:23:21 PDT 2013


Many thanks for this Frank, the reason for the problem should have occurred
to me. As you say, gdalwarp is the answer.

Best wishes,
Nick.


On Tue, May 28, 2013 at 6:15 PM, Frank Warmerdam <warmerdam at pobox.com>wrote:

> 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.
>
>
> Best regards,
> Frank
> --
>
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Software Developer
>

-- 
Nick Hopton, Caversham, Reading, England.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130529/77153026/attachment.html>


More information about the gdal-dev mailing list