[gdal-dev] Weird behavior while reprojecting geometries

Hugo hfpmartins at gmail.com
Fri Mar 4 03:07:01 PST 2022


Hi guys,

I'm having weird behavior using ogr and osr through python while
reprojecting point geometries.

Following code:
wgs = osr.SpatialReference()
wgs.ImportFromEPSG(4326)

etrs = osr.SpatialReference()
etrs.ImportFromEPSG(3763)

geom = ogr.Geometry(ogr.wkbPoint)
geom.AddPoint(-9.10165,38.73981)
#geom.AddPoint(38.73981,-9.10165)
geom.AssignSpatialReference(wgs)

reproj = osr.CoordinateTransformation(wgs, etrs)
geom.Transform(reproj)

If I run it as it is I get wrong coordinates in the target SRS. However if
I switch X,Y when building the geometry (the commented line) I will get the
correct coordinates. What is weird is that I have another script reading
from geonames dataset and there this behavior doesn't happen.

I'm using GDAL 3.4.1 installed through conda on Ubuntu 20.04.

Any hints?
thanks in advance

-- 
Hugo Martins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220304/ce70215b/attachment.html>


More information about the gdal-dev mailing list