[gdal-dev] Cannot set simple geotransform

Sean Gillies sean at mapbox.com
Wed Feb 5 10:06:25 PST 2020


Hi Jon,

On Wed, Feb 5, 2020 at 10:15 AM Jon Morris <Jon.Morris at jbarisk.com> wrote:

> I've just spent most of the afternoon banging my head against the desk
> because it appears that you cannot set a geotransform of (0, 1, 0, 0, 0,
> -1). Any other value works fine, but with this particular GT, the change is
> not saved when you close the ds. Is this a known issue? I'm using GDAL
> 2.2.0 on Python 3.6.8.
>
>
>
> IPython console:
>
>
>
> In [269]:
> ds=gdal.GetDriverByName('GTiff').Create('/tmp/test.tif',5,5,1,gdal.GDT_Byte)
>
>
>
>
> In [270]:
> ds.GetGeoTransform()
>
>
> Out[270]: (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
>
>
>
> In [271]:
> ds.SetGeoTransform((0,1,0,0,0,-1))
>
>
> Out[271]: 0
>
>
>
> In [272]: del ds
>
>
>
>
> In [273]:
> ds=gdal.OpenEx('/tmp/test.tif',gdal.GA_Update)
>
>
>
>
> In [274]:
> ds.GetGeoTransform()
>
>
> Out[274]: (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
>
>
>
> In [275]:
> ds.SetGeoTransform((0,1,0,0,0,-1.000000001))
>
>
> Out[275]: 0
>
>
>
> In [276]: del
> ds
>
>
>
>
> In [277]:
> ds=gdal.OpenEx('/tmp/test.tif',gdal.GA_Update)
>
>
>
>
> In [278]:
> ds.GetGeoTransform()
>
>
> Out[278]: (0.0, 1.0, 0.0, 0.0, 0.0, -1.000000001)
>
>
>
>
>
>
>
> Thanks,
>
>
>
> Jon
>
>
It's a known bug. There is some analysis at
https://github.com/mapbox/rasterio/issues/524#issuecomment-156655258.

Briefly: depending on the format driver, setting the geotransform can be a
no-op if the given transform is ~= the identity transform. For GeoTIFF,
both (0, 1, 0, 0, 0, 1) and (0, 1, 0, 0, 0, -1) are considered to be ~=
identity and are invalid inputs that are ignored.

-- 
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200205/8b246036/attachment-0001.html>


More information about the gdal-dev mailing list