Skip to content

Instantly share code, notes, and snippets.

@richpsharp
Created February 25, 2020 17:31
Show Gist options
  • Select an option

  • Save richpsharp/d10fa2efed2f94eaa5a605dc7fc3a4b4 to your computer and use it in GitHub Desktop.

Select an option

Save richpsharp/d10fa2efed2f94eaa5a605dc7fc3a4b4 to your computer and use it in GitHub Desktop.
example of axis mapping strategy effects on GDAL 3.0
from osgeo import osr
wgs84 = osr.SpatialReference()
wgs84.ImportFromEPSG(4326)
utm10 = osr.SpatialReference()
utm10.ImportFromEPSG(26910)
# Play with these settings, you'll find the utm10 strategey makes no difference bu
# the wgs84 one needs traditional order
wgs84.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
utm10.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
wgs84_to_utm10_transformer = osr.CreateCoordinateTransformation(wgs84, utm10)
utm_10to_wgs84_transformer = osr.CreateCoordinateTransformation(utm10, wgs84)
base_wgs84_point = (-123, 50)
utm_10_point = wgs84_to_utm10_transformer.TransformPoint(*base_wgs84_point)[0:2]
wgs84_point = utm_10to_wgs84_transformer.TransformPoint(*utm_10_point)[0:2]
print('base: %s', base_wgs84_point)
print('utm transform: %s', utm_10_point)
print('wgs back transform: %s', wgs84_point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment