[gdal-dev] Coordinate transformation of geometries between CRSs with different axis ordering (C API)
Florian Katerndahl
florian at katerndahl.com
Wed Apr 1 08:14:04 PDT 2026
Hi Even,
thanks for your reply.
I don't pass the coordinates directly via `OCTTransform` but use
`OGR_GeomTransformer_Transform` to transform polygon geometries. Based
on the fact than when fetching the points that make up the input
polygon, the x and y coordinates match the axis of the input CRS, my
assumption was that I don't need to change the ordering for the input
CRS. Looking at the points in the output geometry, the coordinates are
flipped when not setting OAMS_TRADITIONAL_GIS_ORDER. This was the reason
why I assumed I need to set the axis ordering depending on the CRSs I
translate between.
But if I understand your reply correctly, I should also not need to
touch the axis ordering for the output CRS as GDAL takes care of mapping
the data to CRS axis for the output geometry. I suppose my understanding
is not sufficient enough (yet) to understand the underlying issue then
and I will need to do some further research on my side.
Kind regards,
Florian
On 4/1/26 16:26, Even Rouault wrote:
>
> Le 01/04/2026 à 16:04, Florian Katerndahl via gdal-dev a écrit :
>> Dear all,
>>
>> I'm currently working on a small program which allows users to
>> specify vector inputs in different coordinates systems and that
>> potentially "normalizes" them to EPSG:4326 internally to process them
>> further. Maybe I'm too inexperienced and there's an easy solution but
>> I got hung up on the coordinate transformation when the input CRS has
>> a different axis ordering compared to the output CRS using
>> GDAL's/OGR's C API.
>>
>> For example, transforming between EPSG:5556 and EPSG:4326, GDAL
>> outputs a warning (forwarded from proj?) that the output's latitude
>> is invalid. Setting the axis ordering of the target CRS to
>> `OAMS_TRADITIONAL_GIS_ORDER` fixes this and results in correctly
>> located polygons. My question is now: Is it sufficient/correct to
>> compare the axis ordering of the input and output coordinate systems
>> and set above mentioned flag (or a custom mapping when neither
>> "x"/"y" are the first two axis) in case they differ?
>
> The axis ordering of the input CRS vs the one of the output CRS is
> complelely unrelated w.r.t your decision about setting or not
> OAMS_TRADITIONAL_GIS_ORDER. Setting it or not for the input totally
> depends on your decision how you want to specify the coordinates.
>
>
More information about the gdal-dev
mailing list