Skip to content

Commit

Permalink
sen2meta.py: Cope with non-compatible API change in GDAL 3, in which …
Browse files Browse the repository at this point in the history
…long/lat can be swapped.
  • Loading branch information
Neil Flood authored and Neil Flood committed Nov 29, 2019
1 parent 75fdec7 commit 3071ca2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fmask/sen2meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def getCtrLongLat(self):
srUTM.ImportFromEPSG(int(self.epsg))
srLL = osr.SpatialReference()
srLL.ImportFromEPSG(4326)
if hasattr(srLL, 'SetAxisMappingStrategy'):
# We are in GDAL >= 3, so guard against axis swapping
srLL.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
srUTM.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
tr = osr.CoordinateTransformation(srUTM, srLL)
(longitude, latitude, z) = tr.TransformPoint(ctrX, ctrY)
return (longitude, latitude)
Expand Down

0 comments on commit 3071ca2

Please sign in to comment.