<div dir="ltr"><div><div>Many thanks for this Frank, the reason for the problem should have occurred to me. As you say, gdalwarp is the answer.<br><br></div>Best wishes,<br></div>Nick. <br><div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, May 28, 2013 at 6:15 PM, Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Nick,<div><br></div><div>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. </div>
<div><br></div><div>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. </div>
<div><br></div><div>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. </div>
<div><br></div><div>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. </div><div><br></div><div>
eg. </div><div><br></div><div>gdalwarp 33044071.TIF 33044071_northup.TIF </div><div><br></div><div>This warp will be done using the control points (ironically also using a best fit first order polynomial). </div>
<div><br></div><div>The code responsible for the decision is this from gdal/gcore/gdal_misc.cpp:</div><div><br></div><div><div>/* -------------------------------------------------------------------- */</div>
<div>/* Try to convert the GCPs into a geotransform definition, if */</div><div>/* possible. Otherwise we will need to use them as GCPs. */</div><div>/* -------------------------------------------------------------------- */</div>
<div> if( !GDALGCPsToGeoTransform( nCoordinateCount, asGCPs, padfGeoTransform, </div><div> FALSE ) )</div><div> {</div><div> if (pnGCPCount && ppasGCPs)</div><div> {</div>
<div> CPLDebug( "GDAL", </div><div> "GDALLoadTabFile(%s) found file, wasn't able to derive a\n"</div><div> "first order geotransform. Using points as GCPs.",</div>
<div> pszFilename );</div><div><br></div><div> *ppasGCPs = (GDAL_GCP *) </div><div> CPLCalloc( sizeof(GDAL_GCP),nCoordinateCount );</div><div> memcpy( *ppasGCPs, asGCPs, sizeof(GDAL_GCP) * nCoordinateCount );</div>
<div> *pnGCPCount = nCoordinateCount;</div><div> }</div><div> }</div><div> else</div><div> {</div><div> GDALDeinitGCPs( nCoordinateCount, asGCPs );</div><div> }</div><div><br></div><div>
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. </div><div><br></div><div><br></div></div><div>
Best regards,</div><div>Frank</div></div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888">-- <br>---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush | Geospatial Software Developer<br>
</font></span></div>
</blockquote></div><br>-- <br>Nick Hopton, Caversham, Reading, England.
</div></div></div></div></div>