createWaterMask: add --fill option
+ add --fill option to be able to change the fill value for the missing water body data, because sometimes it's land sometimes it's water.LT1AB
parent
7644bf8c93
commit
b0cecb64cb
|
@ -32,10 +32,16 @@ def createParser():
|
||||||
'and (0,360) or (-180,180) for longitudes.')
|
'and (0,360) or (-180,180) for longitudes.')
|
||||||
parser.add_argument('-d','--dem_file', dest='demName', type=str, default=None,
|
parser.add_argument('-d','--dem_file', dest='demName', type=str, default=None,
|
||||||
help='DEM file in geo coordinates, i.e. demLat*.dem.wgs84.')
|
help='DEM file in geo coordinates, i.e. demLat*.dem.wgs84.')
|
||||||
|
|
||||||
parser.add_argument('-l', '--lat_file', dest='latName', type=str, default=None,
|
parser.add_argument('-l', '--lat_file', dest='latName', type=str, default=None,
|
||||||
help='pixel by pixel lat file in radar coordinate')
|
help='pixel by pixel lat file in radar coordinate')
|
||||||
parser.add_argument('-L', '--lon_file', dest='lonName', type=str, default=None,
|
parser.add_argument('-L', '--lon_file', dest='lonName', type=str, default=None,
|
||||||
help='pixel by pixel lat file in radar coordinate')
|
help='pixel by pixel lat file in radar coordinate')
|
||||||
|
|
||||||
|
parser.add_argument('--fill', dest='fillValue', type=int, default=-1, choices={-1,0},
|
||||||
|
help='fill value for pixels with missing data. Default: -1.\n'
|
||||||
|
'-1 for water body\n'
|
||||||
|
' 0 for land')
|
||||||
parser.add_argument('-o', '--output', dest='outfile', type=str,
|
parser.add_argument('-o', '--output', dest='outfile', type=str,
|
||||||
help='output filename of water mask in radar coordinates')
|
help='output filename of water mask in radar coordinates')
|
||||||
return parser
|
return parser
|
||||||
|
@ -73,7 +79,7 @@ def dem2bbox(dem_file):
|
||||||
return bbox
|
return bbox
|
||||||
|
|
||||||
|
|
||||||
def download_waterMask(bbox, dem_file):
|
def download_waterMask(bbox, dem_file, fill_value=-1):
|
||||||
out_dir = os.getcwd()
|
out_dir = os.getcwd()
|
||||||
# update out_dir and/or bbox if dem_file is input
|
# update out_dir and/or bbox if dem_file is input
|
||||||
if dem_file:
|
if dem_file:
|
||||||
|
@ -86,8 +92,7 @@ def download_waterMask(bbox, dem_file):
|
||||||
#inps.waterBodyGeo = sw.defaultName(inps.bbox)
|
#inps.waterBodyGeo = sw.defaultName(inps.bbox)
|
||||||
sw.outputFile = os.path.join(out_dir, sw.defaultName(bbox))
|
sw.outputFile = os.path.join(out_dir, sw.defaultName(bbox))
|
||||||
sw._noFilling = False
|
sw._noFilling = False
|
||||||
sw._fillingValue = -1.0 #fill pixels without DEM data with value of -1, same as water body
|
sw._fillingValue = fill_value
|
||||||
#sw._fillingValue = 0.0
|
|
||||||
sw.stitch(bbox[0:2], bbox[2:])
|
sw.stitch(bbox[0:2], bbox[2:])
|
||||||
return sw.outputFile
|
return sw.outputFile
|
||||||
|
|
||||||
|
@ -106,7 +111,7 @@ def geo2radar(geo_file, rdr_file, lat_file, lon_file):
|
||||||
def main(iargs=None):
|
def main(iargs=None):
|
||||||
|
|
||||||
inps = cmdLineParse(iargs)
|
inps = cmdLineParse(iargs)
|
||||||
geo_file = download_waterMask(inps.bbox, inps.demName)
|
geo_file = download_waterMask(inps.bbox, inps.demName, inps.fillValue)
|
||||||
if inps.latName and inps.lonName:
|
if inps.latName and inps.lonName:
|
||||||
geo2radar(geo_file, inps.outfile, inps.latName, inps.lonName)
|
geo2radar(geo_file, inps.outfile, inps.latName, inps.lonName)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue