Commit 0a0b12e5 authored by Lozac'h Loic's avatar Lozac'h Loic

UPDATE: ref must be in proj coord for slope

parent 2ee81189
......@@ -21,6 +21,7 @@ namespaces = {
'gml': "http://www.opengis.net/gml"
}
overwrite=False
slope=True
def search_files(directory='.', resolution='S1', extension='SAFE', fictype='d'):
images=[]
......@@ -210,11 +211,12 @@ def create_zone_dem_and_slope(ref,zone,outdir):
supapp.ExecuteAndWriteOutput()
#Compute slope
print("Generating slope file...")
outslope = os.path.join(outdir,"SLOPE_"+zone+".TIF")
cmd=['gdaldem', 'slope', '-p', outdem, outslope]
process_command(cmd)
if slope :
print("Generating slope file...")
outslope = os.path.join(outdir,"SLOPE_"+zone+".TIF")
cmd=['gdaldem', 'slope', '-p', outdem, outslope]
process_command(cmd)
return outdem
......@@ -390,21 +392,30 @@ if __name__ == "__main__":
# Make parser object
parser = argparse.ArgumentParser(description=
"""
Compute cloud-masked NDVI from Sentinel2 or Landsat8.
S1 Calibration, orhorectification, dem, slope and incidence angle processing
""")
parser.add_argument('-indir', action='store', required=True, help='Directory containing Sentinel1 SNAP Calibrated or Landsat8 NDVI')
parser.add_argument('-inref', action='store', required=True, help='Image references Sentinel-2 Tile, example any S2 NDVI')
parser.add_argument('-indir', action='store', required=True, help='Directory containing Sentinel1 SAFE dir')
parser.add_argument('-inref', action='store', required=True, help='Image reference, generally corresponding to a S2 tile')
parser.add_argument('-zone', action='store', required=True, help='Geographic zone reference for output files naming')
parser.add_argument('-outdir', action='store', required=True, help='Output directory')
parser.add_argument('-overwrite', dest='overwrite', action='store_true',required=False, help='[Optional] Overwrite already existing files (default False)')
parser.add_argument('--no-slope', dest='slope', action='store_false',required=False, help="[Optional] Don't create slope from dem (default True), MUST have ref image in projected coordinates")
parser.add_argument('--overwrite', dest='overwrite', action='store_true',required=False, help='[Optional] Overwrite already existing files (default False)')
parser.set_defaults(overwrite=False)
args=parser.parse_args()
slope = args.slope
overwrite = args.overwrite
if slope:
raster = gdal.Open(args.inref)
proj = osr.SpatialReference(wkt=raster.GetProjection())
if proj.IsGeographic() :
print("Error: Reference image must be in projected coordinates in order to create slope")
exit()
if not os.path.exists(args.outdir):
os.mkdir(args.outdir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment