From 3b67950fc796f633d4edcdbed079e7824e64a728 Mon Sep 17 00:00:00 2001 From: yunjunz Date: Sat, 22 May 2021 17:24:26 -0700 Subject: [PATCH] stripmapStack.createWaterMask: skip re-dload if wbd file exists --- contrib/stack/stripmapStack/createWaterMask.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/contrib/stack/stripmapStack/createWaterMask.py b/contrib/stack/stripmapStack/createWaterMask.py index 1f0076f8..f6827152 100755 --- a/contrib/stack/stripmapStack/createWaterMask.py +++ b/contrib/stack/stripmapStack/createWaterMask.py @@ -86,19 +86,25 @@ def download_waterMask(bbox, dem_file, fill_value=-1): out_dir = os.path.dirname(dem_file) if not bbox: bbox = dem2bbox(dem_file) + print('bounding box in (S, N, W, E): {}'.format(bbox)) sw = createManager('wbd') sw.configure() #inps.waterBodyGeo = sw.defaultName(inps.bbox) sw.outputFile = os.path.join(out_dir, sw.defaultName(bbox)) - sw._noFilling = False - sw._fillingValue = fill_value - sw.stitch(bbox[0:2], bbox[2:]) + if os.path.isfile(sw.outputFile): + print('wbd file already exists at: {}'.format(sw.outputFile)) + print('skip re-downloading and continue') + else: + sw._noFilling = False + sw._fillingValue = fill_value + sw.stitch(bbox[0:2], bbox[2:]) return sw.outputFile def geo2radar(geo_file, rdr_file, lat_file, lon_file): #inps.waterBodyRadar = inps.waterBodyGeo + '.rdr' + print('converting water mask file to radar coordinates ...') sw = SWBDStitcher() sw.toRadar(geo_file, lat_file, lon_file, rdr_file) return rdr_file