<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Le 10/09/2024 à 02:55, Fox, Shawn D
(US) via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:20240910005641.D5B94614250A@lists.osgeo.org">
<pre class="moz-quote-pre" wrap="">Evan,
Thanks for putting some time into that response and showing some examples. Perhaps I should clarify exactly how our software is using GDAL. I thought that it was easier to show the problem using gdaltransform rather than source code, but that does lack some context. Here is crude, but simple example of how the C Apis are being used.</pre>
</blockquote>
<span style="white-space: pre-wrap">
</span>
<blockquote type="cite"
cite="mid:20240910005641.D5B94614250A@lists.osgeo.org">
<pre class="moz-quote-pre" wrap="">
--- source code begin ---
OGRSpatialReferenceH sourceSRS = OSRNewSpatialReference(NULL);
OGRSpatialReferenceH targetSRS = OSRNewSpatialReference(NULL);
errorSource = OSRSetWellKnownGeogCS( sourceSRS, "NAD27");
errorTarget = OSRSetWellKnownGeogCS( targetSRS, "WGS84");
OGRCoordinateTransformationH ptrCT = OCTNewCoordinateTransformation( sourceSRS, targetSRS );
status = OCTTransform( ptrCT, 1, x_lon, y_lat, NULL );</pre>
</blockquote>
<p>Source code speaks for itself :-) This is a CRS axis order issue.
Cf
<a class="moz-txt-link-freetext" href="https://gdal.org/en/latest/tutorials/osr_api_tut.html#crs-and-axis-order">https://gdal.org/en/latest/tutorials/osr_api_tut.html#crs-and-axis-order</a>
for the whole discussion<br>
</p>
<p>With your current code and GDAL >= 3, the input axis order
should be (lat, lon) since NAD27 in EPSG is declared as (lat, lon)
ordered and GDAL 3 honours that by default</p>
<p>If you want to keep long, lat axis order, add
OSRSetAxisMappingStrategy(errorSource,
OAMS_TRADITIONAL_GIS_ORDER); and
OSRSetAxisMappingStrategy(errorTarget,
OAMS_TRADITIONAL_GIS_ORDER); before creating the coordinate
transformation</p>
<p>Even</p>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>