[gdal-dev] GDALApplyGeoTransform

Even Rouault even.rouault at spatialys.com
Wed Feb 17 02:12:19 PST 2016


Le mercredi 17 février 2016 00:23:26, Andrew Bell a écrit :
> Hi,
> 
> I'm trying to understand why GDALApplyGeoTransform behaves as it does.
> I would think that when you use it to transform a raster coordinate to
> a geo coordinate, it would apply what is known about the raster and
> the transformation to get the correct location.  What I see happening
> is some drivers is an adjustment to "center" the points in the middle
> of a raster cell.  This is fine, but I don't understand why
> GDALApplyGeoTransform doesn't do this if this is always the proper
> operation. 

GDALApplyGeoTransform() doesn't do this, as adjusting to pixel center or pixel 
top-left corner depends on the convention of each driver (and for some drivers 
like GTiff, both conventions can exist depending on datasets), so the logic is 
in driver code.


> The GeoTiff spec (see 2.5.2.2) says that this behavior is
> the default unless the key GTRasterTypeGeoKey is set to
> RasterPixelIsPoint.
> 
> Then I found this:
> https://trac.osgeo.org/gdal/wiki/rfc33_gtiff_pixelispoint which was
> supposed to address this issue, but I'm not sure it was implemented or
> how.

This is implemented in the GTiff driver.

> 
> Anyway, I'm not sure what's supposed to happen and I'm not sure why I
> should have to manually adjust a pixel's position when converted to a
> geolocation rather than expect the correct value to be generated by
> GDALApplyGeoTransform.

Drivers that need to convert from a format pixel-is-center logic to the GDAL 
pixel-origin-at-top-left-corner convention already do that by altering their 
geotransform matrix, so if you apply GDALApplyGeoTransform() you should get 
the "correct" answer (assuming you use the GDAL convention for your input 
values)

> 
> Of course, I may well be missing something, so please correct me if I am.
> 
> Thanks,

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list