Skip to content

Commit f149813

Browse files
yunjunzpiyushrpt
authored andcommitted
update system call of gdal2isce_xml with python interface
+ update os.system() call of gdal2isce_xml.py with the python function call, in stripmapStack/topo.py and applications/downsampleDEM.py + break the long lines in downsampleDEM.py for easy reading
1 parent f06d22e commit f149813

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

applications/downsampleDEM.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030

3131

3232

33-
33+
import os
3434
import sys
3535
import argparse
36-
import os
3736
from osgeo import gdal
37+
from isce.applications.gdal2isce_xml import gdal2isce_xml
38+
3839

3940
# command line parsing of input file
4041
def cmdLineParse():
@@ -62,22 +63,32 @@ def cmdLineParse():
6263

6364
# check if the input file exist
6465
if not os.path.isfile(inps.input_dem_vrt):
65-
raise Exception('Input file is not found ....')
66+
raise Exception('Input file is not found ....')
6667
# check if the provided input file is a .vrt file and also get the envi filename
6768
input_dem_envi, file_extension = os.path.splitext(inps.input_dem_vrt)
6869
if file_extension != '.vrt':
69-
raise Exception('Input file is not a vrt file ....')
70+
raise Exception('Input file is not a vrt file ....')
7071
# get the file path
7172
input_path = os.path.dirname(os.path.abspath(inps.input_dem_vrt))
7273

7374

7475
# convert the output resolution from m in degrees
7576
# (this is approximate, could use instead exact expression)
7677
if inps.res_meter != '':
77-
gdal_opts = gdal.WarpOptions(format='ENVI',outputType=gdal.GDT_Int16,dstSRS='EPSG:4326',xRes=float(inps.res_meter)/110/1000,yRes=float(inps.res_meter)/110/1000,targetAlignedPixels=True)
78+
gdal_opts = gdal.WarpOptions(format='ENVI',
79+
outputType=gdal.GDT_Int16,
80+
dstSRS='EPSG:4326',
81+
xRes=float(inps.res_meter)/110/1000,
82+
yRes=float(inps.res_meter)/110/1000,
83+
targetAlignedPixels=True)
7884
# res_degree = float(inps.res_meter)/110/1000
7985
elif inps.res_seconds != '':
80-
gdal_opts = gdal.WarpOptions(format='ENVI',outputType=gdal.GDT_Int16,dstSRS='EPSG:4326',xRes=float(inps.res_seconds)*1/60*1/60,yRes=float(inps.res_seconds)*1/60*1/60,targetAlignedPixels=True)
86+
gdal_opts = gdal.WarpOptions(format='ENVI',
87+
outputType=gdal.GDT_Int16,
88+
dstSRS='EPSG:4326',
89+
xRes=float(inps.res_seconds)*1/60*1/60,
90+
yRes=float(inps.res_seconds)*1/60*1/60,
91+
targetAlignedPixels=True)
8192
# res_degree = float(1/60*1/60*float(inps.res_seconds))
8293

8394
# The ENVI filename of the coarse DEM to be generated
@@ -90,5 +101,5 @@ def cmdLineParse():
90101
ds = None
91102

92103
# Generating the ISCE xml and vrt of this coarse DEM
93-
cmd = "gdal2isce_xml.py -i " + coarse_dem_envi
94-
os.system(cmd)
104+
gdal2isce_xml(coarse_dem_envi+'.vrt')
105+

contrib/stack/stripmapStack/topo.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,8 @@ def runMultilook(in_dir, out_dir, alks, rlks, in_ext='.rdr', out_ext='.rdr', met
419419

420420
# generate ISCE .xml file
421421
if not os.path.isfile(out_file+'.xml'):
422-
cmd = 'gdal2isce_xml.py -i {}.vrt'.format(out_file)
423-
print(cmd)
424-
os.system(cmd)
422+
from isce.applications.gdal2isce_xml import gdal2isce_xml
423+
gdal2isce_xml(out_file+'.vrt')
425424

426425
else:
427426
raise ValueError('un-supported multilook method: {}'.format(method))

0 commit comments

Comments
 (0)