Re: [gdal-dev] Cannot set simple geotransform

2020-02-05 Thread Jon Morris
That's great to know, thanks both. Really must get on with that upgrade to GDAL 
3...

Thanks,

Jon

-Original Message-
From: gdal-dev  On Behalf Of Even Rouault
Sent: 05 February 2020 18:31
To: gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Cannot set simple geotransform

> It's a known bug. There is some analysis at
> https://github.com/mapbox/rasterio/issues/524#issuecomment-156655258.

Actually, is a *past* known bug, at least for the GTiff driver

From GDAL 2.3.0 news:
 * make it accept to write SetGeoTransform([0,1,0,0,0,1]) as a 
ModelTransformationTag, and remove particular cases with the [0,1,0,0,0,1] 
geotransform (#1683)

This fix also fixes (0,1,0,0,0,-1)

>>> from osgeo import gdal
ds=gdal.GetDriverByName('GTiff').Create('/tmp/test.tif',5,5,1,gdal.GDT_Byte)
>>> ds=gdal.GetDriverByName('GTiff').Create('/tmp/test.tif',
5,5,1,gdal.GDT_Byte)
>>> ds.GetGeoTransform()
(0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
>>> ds.SetGeoTransform((0,1,0,0,0,-1))
0
>>> del ds
>>> ds=gdal.OpenEx('/tmp/test.tif',gdal.GA_Update)
>>> ds.GetGeoTransform()
(0.0, 1.0, 0.0, 0.0, 0.0, -1.0)
>>>


--
Spatialys - Geospatial professional services http://www.spatialys.com 
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
T +44 (0) 1756 799919
www.jbarisk.com<http://www.jbarisk.com>

[Visit our website]<http://www.jbarisk.com> 
[http://www.jbagroup.co.uk/imgstore/JBA-Email-Sig-Icons-LINKEDIN.png] 
<https://www.linkedin.com/in/jon-morris-a2897b4/>  [Follow us on Twitter] 
<https://twitter.com/jbarisk>
Our postal address and registered office is JBA Risk Management Limited, 1 
Broughton Park, Old Lane North, Broughton, Skipton, North Yorkshire BD23 3FD.
Find out more about us here: www.jbarisk.com<http://www.jbarisk.com/> and 
follow us on Twitter @JBARisk<http://twitter.com/JBARisk> and 
LinkedIn<https://www.linkedin.com/company/2370847?trk=tyah=clickedVertical%3Acompany%2CclickedEntityId%3A2370847%2Cidx%3A2-1-2%2CtarId%3A1447414259786%2Ctas%3AJBA%20RISK%20MANAGEMENT>

The JBA Group supports the JBA Trust.

All JBA Risk Management's email messages contain confidential information and 
are intended only for the individual(s) named. If you are not the named 
addressee you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by email if you have received this email 
by mistake and delete this email from your system.


JBA Risk Management Limited is registered in England, company number 07732946, 
1 Broughton Park, Old Lane North, Broughton, Skipton, North Yorkshire, BD23 
3FD, Telephone: +441756799919


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Cannot set simple geotransform

2020-02-05 Thread Even Rouault
> It's a known bug. There is some analysis at
> https://github.com/mapbox/rasterio/issues/524#issuecomment-156655258.

Actually, is a *past* known bug, at least for the GTiff driver

From GDAL 2.3.0 news:
 * make it accept to write SetGeoTransform([0,1,0,0,0,1]) as a 
ModelTransformationTag, and remove particular cases with the [0,1,0,0,0,1] 
geotransform (#1683)

This fix also fixes (0,1,0,0,0,-1)

>>> from osgeo import gdal
ds=gdal.GetDriverByName('GTiff').Create('/tmp/test.tif',5,5,1,gdal.GDT_Byte)
 
>>> ds=gdal.GetDriverByName('GTiff').Create('/tmp/test.tif',
5,5,1,gdal.GDT_Byte) 
>>> ds.GetGeoTransform() 
(0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
>>> ds.SetGeoTransform((0,1,0,0,0,-1)) 
0
>>> del ds   
>>> ds=gdal.OpenEx('/tmp/test.tif',gdal.GA_Update)
>>> ds.GetGeoTransform() 
(0.0, 1.0, 0.0, 0.0, 0.0, -1.0)
>>> 


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Cannot set simple geotransform

2020-02-05 Thread Sean Gillies
Hi Jon,

On Wed, Feb 5, 2020 at 10:15 AM Jon Morris  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.1))
>
>
> 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.1)
>
>
>
>
>
>
>
> 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
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev