Commit 5bad1bd1 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

FIX: GDAL3 compatibility issues.

parent fc4f6f25
......@@ -299,6 +299,9 @@ def getRasterExtentAsGeometry(ras_ds, to_wgs84=False):
ras_srs = osr.SpatialReference(wkt=ras_ds.GetProjection())
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
# For retro-compatibility issues
if gdal.VersionInfo()[0] == '3':
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
poly.AssignSpatialReference(ras_srs)
poly.TransformTo(out_srs)
......
......@@ -19,6 +19,15 @@ import elevation
# - rasterize vector on
# - check possibilities to update filter outcore to make filtering on a temporal moving window
def getS1ExtentGeometry(s1file):
t = ET.parse(os.path.dirname(s1file) + os.sep + os.pardir + os.sep + 'preview' + os.sep + 'map-overlay.kml')
r = t.getroot()
coords = r[0][1][1][2][0].text.split(' ')
coords = [x.split(',') for x in coords]
wkt = [x[0] + ' ' + x[1] + ' 0' for x in coords] + [coords[0][0] + ' ' + coords[0][1] + ' 0']
out = ogr.CreateGeometryFromWkt('POLYGON ((' + ','.join(wkt) + '))')
return out
def download_srtm1(roi_vector, outfile, cache_dir=Path('~/.moringa/cache').expanduser(), max_download_tiles=9,
overwrite=False):
"""
......@@ -173,18 +182,13 @@ def S1CalibOrthoWithROI(infile, outfile, roi, demfld, geoid, lut='sigma', overwr
return None
def checkRoiInS1Acquisition(s1file, roifile):
isIntersecting = False
dsv = gdal.Open(roifile)
roi_geom = getRasterExtentAsGeometry(dsv, to_wgs84=True)
print(roi_geom.ExportToWkt())
dsi = ogr.Open(os.path.dirname(s1file) + os.sep + os.pardir + os.sep + 'preview' + os.sep + 'map-overlay.kml')
lyi = dsi.GetLayer()
for g in lyi:
in_geom = g.GetGeometryRef()
roi_geom = getRasterExtentAsGeometry(dsv, to_wgs84=True, lat_lon=True)
in_geom = getS1ExtentGeometry(s1file)
isIntersecting = in_geom.Intersects(roi_geom)
print(in_geom.ExportToWkt())
dsv = None
dsi = None
print(roi_geom.ExportToWkt())
print(in_geom.ExportToWkt())
return isIntersecting
def preClip(infile, outfile, roi_buffered_vector, overwrite=False, verbose=True, ram=1024):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment