From be959c3b27bdcc5b3201330bcd4440b783c34258 Mon Sep 17 00:00:00 2001 From: sssangha Date: Fri, 17 Apr 2020 19:57:52 -0700 Subject: [PATCH] Download of nasadem now supported in dem.py --- applications/dem.py | 7 +++++-- contrib/demUtils/__init__.py | 4 +++- contrib/demUtils/demstitcher/DemStitcher.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/applications/dem.py b/applications/dem.py index a4f5fc6..9cb307f 100755 --- a/applications/dem.py +++ b/applications/dem.py @@ -82,7 +82,7 @@ def main(): parser.add_argument('-n', '--uname', type = str, dest = 'uname', default = None, help = 'User name if using a server that requires authentication') parser.add_argument('-w', '--password', type = str, dest = 'password', default = None, help = 'Password if using a server that requires authentication') parser.add_argument('-t', '--type', type = str, dest = 'type', default = 'version3', help = \ - 'Use version 3 or version 2 SRTM') + 'Use version 3 or version 2 SRTM, or nasadem') parser.add_argument('-x', '--noextras', action = 'store_true', dest = 'noextras', help = 'Use this flag if the filenames do not have extra part') parser.add_argument('-u', '--url', type = str, dest = 'url', default = None, help = \ 'If --type=version2 then this is part of the url where the DEM files are located. The actual location must be' + \ @@ -91,10 +91,13 @@ def main(): args = parser.parse_args() #first get the url,uname and password since are needed in the constructor - ds = createDemStitcher(args.type) ds.configure() + #NASADEM only available in 1-arc sec resolution + if(args.type == 'nasadem'): + args.source == 1 + if(args.url): if(args.type == 'version3'): if(args.source == 1): diff --git a/contrib/demUtils/__init__.py b/contrib/demUtils/__init__.py index 999dd89..db16265 100755 --- a/contrib/demUtils/__init__.py +++ b/contrib/demUtils/__init__.py @@ -32,6 +32,8 @@ def createDemStitcher(type='version3',name = ''): from contrib.demUtils.DemStitcherV3 import DemStitcher if(type == 'version2'): from contrib.demUtils.DemStitcher import DemStitcher + if(type == 'nasadem'): + from contrib.demUtils.DemStitcherV3 import DemStitcher return DemStitcher(name=name) def createSWBDStitcher(name = ''): from contrib.demUtils.SWBDStitcher import SWBDStitcher @@ -56,4 +58,4 @@ def getFactoriesInfo(): { 'factory':'createCorrect_geoid_i2_srtm' } - } \ No newline at end of file + } diff --git a/contrib/demUtils/demstitcher/DemStitcher.py b/contrib/demUtils/demstitcher/DemStitcher.py index ff36cce..0cbc6f1 100755 --- a/contrib/demUtils/demstitcher/DemStitcher.py +++ b/contrib/demUtils/demstitcher/DemStitcher.py @@ -763,6 +763,7 @@ class DemStitcher(Component): def getUnzippedName(self,name,source = None): return name.replace(self._zip,'') def stitchDems(self,lat,lon,source, outname, downloadDir = None,region = None, keep = None, swap = None): + import glob if downloadDir is None: downloadDir = self._downloadDir else: @@ -839,7 +840,8 @@ class DemStitcher(Component): if not self._keepDems: for dem in decompressedList: - os.remove(dem) + for d in glob.glob('*'+os.path.basename(dem.decode('UTF-8'))[:7]+'*'): + os.remove(d) if self._createXmlMetadata: self.createXmlMetadata(lat,lon,source,outname) if self._createRscMetadata: