[gdal-dev] Different results for osr.CoordinateTransformation() when using gdal 3.0.1 and 2.4.2 python bindings and transform to EPSG:4326

Klaus Braun klaus.braun at geographie.uni-freiburg.de
Thu Sep 19 06:08:48 PDT 2019


Hi,

on my SUSE box I compiled gdal 2.4.2 and 3.0.1 in the same way, enabling python
bindings.

When I use osr.CoordinateTransformation() in my python script to do a coordinate
transformation from a point to EPSG 4326 the resulting coordinates are swaped if
I use gdal 3.0.1 python bindings.

Any idea what might be the problem in this case?

Regards

Klaus



Example
-------

import sys

#
# Select GDAL version
#
sys.path.insert(0,'/usr/local/gdal/lib64/python2.7/site-packages/GDAL-2.4.2-py2.7-linux-x86_64.egg')
##sys.path.insert(0,'/usr/local/gdal-3.0.1/lib64/python2.7/site-packages/GDAL-3.0.1-py2.7-linux-x86_64.egg')

from osgeo import gdal
from osgeo import ogr
from osgeo import osr

print "GDAL Version: " + str(gdal.__version__)

target = osr.SpatialReference()
target.ImportFromEPSG(4326)

source = osr.SpatialReference()
source.ImportFromEPSG(3857)

transform = osr.CoordinateTransformation(source, target)

#
# Lower left point of EPSG 3857 bounding box
#
point = ogr.CreateGeometryFromWkt("POINT (-20026376.39 -20048966.10)")
point.Transform(transform)

print point.ExportToWkt()


Results
-------

GDAL Version: 2.4.2
POINT (-179.899999966673 -85.0599999968944)

GDAL Version: 3.0.1
POINT (-85.0599999968945 -179.899999966673)




-- 
Dr. Klaus Braun
Albert-Ludwigs-Universität
Physische Geographie
Schreiberstr. 20, D-79085 Freiburg, Germany
phone: ++49 (0)761 203-9223
http://geographie.uni-freiburg.de/


More information about the gdal-dev mailing list