Skip to content

Commit

Permalink
Landsat8: Fix lat/lon swapping for gdal v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteinmetz committed Sep 3, 2020
1 parent 470e103 commit ce64153
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions eoread/landsat8_oli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import dask.array as da
import pyproj
try:
import osr
from osgeo import gdal
from osgeo import gdal, osr
import osgeo
gdal_major_version = int(osgeo.__version__.split('.')[0])
except ModuleNotFoundError:
osr = None
gdal = None
gdal_major_version = None
from . import common
from .naming import naming
from . import eo
Expand Down Expand Up @@ -264,6 +266,9 @@ def __init__(self, dirname, kind, dtype='float32'):

b1 = gdal.Open(file_B1)
old_cs = osr.SpatialReference()
if gdal_major_version >= 3:
# GDAL 3 changes axis order: https://github.com/OSGeo/gdal/issues/1546
old_cs.SetAxisMappingStrategy(osgeo.osr.OAMS_TRADITIONAL_GIS_ORDER)
old_cs.ImportFromWkt(b1.GetProjectionRef())

# create the new coordinate system
Expand All @@ -279,6 +284,9 @@ def __init__(self, dirname, kind, dtype='float32'):
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]"""
new_cs = osr.SpatialReference()
if gdal_major_version >= 3:
# GDAL 3 changes axis order: https://github.com/OSGeo/gdal/issues/1546
new_cs.SetAxisMappingStrategy(osgeo.osr.OAMS_TRADITIONAL_GIS_ORDER)
new_cs.ImportFromWkt(wgs84_wkt)

# create a transform object to convert between coordinate systems
Expand Down

0 comments on commit ce64153

Please sign in to comment.