Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions touchterrain/common/TouchTerrainEarthEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ def get_zipped_tiles(DEM_name=None, trlat=None, trlon=None, bllat=None, bllon=No

else:
filename = os.path.basename(importedDEM)
folder = os.path.dirname(importedDEM)

if bottom_elevation != None:
btxt = "and " + bottom_elevation
Expand All @@ -1202,21 +1203,20 @@ def get_zipped_tiles(DEM_name=None, trlat=None, trlon=None, bllat=None, bllon=No

# If we have a KML file, use it to mask (clip) and crop the importedDEM
if poly_file != None and poly_file != '':
clipped_geotiff = "clipped_" + filename
clipped_geotiff = os.path.join(folder, "clipped_" + filename)

try:
gdal.Warp(clipped_geotiff, filename,
format='GTiff',
warpOptions=['CUTLINE_ALL_TOUCHED=TRUE'],
cutlineDSName=poly_file,
cropToCutline=True,
dstNodata=-32768)
gdal.Warp(clipped_geotiff, importedDEM,
format='GTiff',
warpOptions=['CUTLINE_ALL_TOUCHED=TRUE'],
cutlineDSName=poly_file,
cropToCutline=True,
dstNodata=-32768)
except Exception as e:
pr("clipping", filename, "with", poly_file, "failed, using unclipped geotiff. ", e)
pr("clipping", importedDEM, "with", poly_file, "failed, using unclipped geotiff. ", e)
else:
pr("clipped", filename, "with", poly_file, "now using", clipped_geotiff, "instead")
folder = os.path.split(importedDEM)[0]
importedDEM = os.path.join(folder, clipped_geotiff)
pr("clipped", importedDEM, "with", poly_file, "now using", clipped_geotiff, "instead")
importedDEM = clipped_geotiff

# Make numpy array from imported geotiff
dem = gdal.Open(importedDEM)
Expand Down