[gdal-dev] Weird behavior while reprojecting geometries

Hugo hfpmartins at gmail.com
Fri Mar 4 03:29:53 PST 2022


Hi Idan,

It is indeed this the issue. I was not aware of this change. Man, it has
been a while since I have touched GDAL.
Thanks a lot for your help.

Idan Miara <idan at miara.com> escreveu no dia sexta, 4/03/2022 à(s) 12:13:

>
>
> On Fri, 4 Mar 2022, 13:12 Idan Miara, <idan at miara.com> wrote:
>
>> Hi,
>> Are you familiar with the axis order that was introduced in gdal 3 and
>> its affects on 4326?
>> https://gdal.org/tutorials/osr_api_tut.html#crs-and-axis-order
>>
>> On Fri, 4 Mar 2022, 13:07 Hugo, <hfpmartins at gmail.com> wrote:
>>
>>> 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
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>
>>

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


More information about the gdal-dev mailing list