<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Arial",sans-serif;
color:windowtext;}
span.monaco-highlighted-label
{mso-style-name:monaco-highlighted-label;}
span.value
{mso-style-name:value;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Arial",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">To give a somewhat more concise example:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">from osgeo import gdal, osr, ogr<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">projection = osr.SpatialReference()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">projection.ImportFromEPSG(4326)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">temp_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">layer = temp_ds.CreateLayer("foo", projection, geom_type=ogr.wkbPolygon)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">projFromLayer = layer.GetSpatialRef()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">xform = osr.CoordinateTransformation(projection, projFromLayer)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">xform.TransformPoint(1.0, 0.0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"># Outputs (0.0, 1.0, 0.0)<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">xform_no_layer = osr.CoordinateTransformation(projection, projection)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">xform_no_layer.TransformPoint(1.0, 0.0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"># Outputs (1.0, 0.0, 0.0)<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB">Dr. Daniel Evans</span></b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#F6A124;mso-fareast-language:EN-GB">Software Developer</span><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#F6A124;mso-fareast-language:EN-GB"> </span><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><a href="sip:daniel.evans@jbarisk.com"><b><span style="color:#F6A124">Skype</span></b></a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB"> Daniel Evans
<br>
<b>Sent:</b> 06 February 2020 10:21<br>
<b>To:</b> gdal-dev@lists.osgeo.org<br>
<b>Subject:</b> WGS84 -> WGS84 transform flips axes<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a name="x__MailAutoSig"><span style="font-family:"Arial",sans-serif">I am currently looking at upgrading from GDAL 2.x to GDAL 3.x. Most of my software tests pass, but I have a few failing because a transform from WGS84 to WGS84 is flipping
the axes on transformed geometries. <o:p></o:p></span></a></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">I have a recollection of reading about GDAL 3 (or PROJ 6) resulting in axis swapping in some cases, but can’t find the discussion/Github issue again.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">The two SRS objects appear identical, and seem to report the same axis order, but a point at (1, 0) gets transformed to (0, 1) – Python code below:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> from_proj = ds.GetLayer().GetSpatialRef()<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj = osr.SpatialReference()<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj.ImportFromEPSG(4326)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj.GetAxisName(None, 0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'Geodetic latitude'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj.GetAxisName(None, 1)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'Geodetic longitude'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> from_proj.GetAxisName(None, 0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'Geodetic latitude'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> from_proj.GetAxisName(None, 1)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'Geodetic longitude'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> xform = osr.CoordinateTransformation(from_proj, to_proj)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> xform.TransformPoint(1.0, 0.0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">(0.0, 1.0, 0.0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">If I follow from_proj back to its origin, it is also imported by importing from an EPSG code, which is again 4326:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> projection = osr.SpatialReference()<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> projection.ImportFromEPSG(epsg)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> temp_ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> layer = temp_ds.CreateLayer(name, projection, geom_type=geom_type)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">The two SRS objects appear identical when exported to WKT:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> from_proj.ExportToWkt()<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj.ExportToWkt()<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]'<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">And if I re-import the SRSes from those WKT strings, the transform starts to behave:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> from_proj_reimported = osr.SpatialReference(); from_proj_reimported.ImportFromWkt(from_proj.ExportToWkt())<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> to_proj_reimported = osr.SpatialReference(); to_proj_reimported.ImportFromWkt(to_proj.ExportToWkt())<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> new_xform = osr.CoordinateTransformation(from_proj_reimported, to_proj_reimported)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">>>> new_xform.TransformPoint(1.0, 0.0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">(1.0, 0.0, 0.0)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif">How are these two SRS objects ending up with flipped axes, how can I actually tell that the axes are flipped, and what do I need to do to un-flip them
(short of exporting and reimporting every time I use them)?<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p> </o:p></span></b></span></p>
<p class="MsoNormal"><span style="mso-bookmark:x__MailAutoSig"><b><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB">Dr. Daniel Evans</span></b></span><span style="mso-bookmark:x__MailAutoSig"></span><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#F6A124;mso-fareast-language:EN-GB">Software Developer</span><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#F6A124;mso-fareast-language:EN-GB"> </span><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:black;mso-fareast-language:EN-GB"><a href="sip:daniel.evans@jbarisk.com"><b><span style="color:#F6A124">Skype</span></b></a><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p><strong><span style="color: #f6a125; font-family:arial;">T</span></strong><span style="text-decoration: none; color: #000000; font-family:arial;"> +44 (0) 1756 799919</span><br>
<a style="text-decoration: none; color: #f6a125; font-family:arial;" href="http://www.jbarisk.com">www.jbarisk.com</a></p>
<p><a href="http://www.jbarisk.com"><img src="http://www.jbagroup.co.uk/imgstore/JBA-Email-Sig-Icons-JBA.png" alt="Visit our website" width="33" height="26"></a> <a href=""><img src="http://www.jbagroup.co.uk/imgstore/JBA-Email-Sig-Icons-LINKEDIN.png" alt="" height="26"></a>
<a href="https://twitter.com/jbarisk"><img src="http://www.jbagroup.co.uk/imgstore/JBA-Email-Sig-Icons-TWITTER.png" alt="Follow us on Twitter" width="33" height="26"></a></p>
<o:p></o:p>
<p></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#FF9C00">Our postal address and registered office is JBA Risk Management</span><span style="font-family:"Arial",sans-serif;color:black">
</span><span style="font-family:"Arial",sans-serif;color:#FF9C00">Limited, 1 Broughton Park, Old Lane North, Broughton, Skipton, North Yorkshire BD23 3FD.</span><o:p></o:p></p>
<p><b><span style="background: white; color: black; font-family: "Arial",sans-serif; font-size: 10pt;">Find out more about us here:
<a href="http://www.jbarisk.com/"><font color="#0563c1">www.jbarisk.com</font></a> and
</span></b><b><span style="background: white; color: rgb(68, 68, 68); font-family: "Arial",sans-serif; font-size: 10pt;"><a href="http://twitter.com/JBARisk" target="_blank"><font color="#0563c1">follow us on Twitter @JBARisk</font></a> and
<a href="https://www.linkedin.com/company/2370847?trk=tyah&trkInfo=clickedVertical%3Acompany%2CclickedEntityId%3A2370847%2Cidx%3A2-1-2%2CtarId%3A1447414259786%2Ctas%3AJBA%20RISK%20MANAGEMENT">
<font color="#0563c1">LinkedIn</font></a> </span></b></p>
<p><span style="background: white; color: black; font-family: "Arial",sans-serif; font-size: 8pt;">The JBA Group supports the JBA Trust.</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="background: white; color: rgb(68, 68, 68); font-family: "Arial",sans-serif; font-size: 8pt;">All JBA Risk Management's email messages contain confidential information and are intended only for the individual(s) named.
If you are not the named addressee you should not disseminate, distribute or copy this e-mail.</span><br>
<span style="color: rgb(68, 68, 68); font-family: "Arial",sans-serif; font-size: 8pt;"><span style="background: white;">Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system.</span></span><br>
</p>
<p style="margin: 0cm 0cm 0pt;"><span style="color: rgb(68, 68, 68); font-family: "Arial",sans-serif; font-size: 8pt;"><span style="background: white;">JBA Risk Management Limited is registered in England, company number 07732946, 1 Broughton Park, Old Lane
North, Broughton, Skipton, North Yorkshire, BD23 3FD, </span></span><span style="background: white; color: black; font-family: "Arial",sans-serif; font-size: 8pt;">Telephone: +441756799919</span></p>
<p> </p>
</body>
</html>