Commit afc7cf26 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

Improved masking

parent 167c2650
......@@ -430,8 +430,17 @@ class LandscapeStratification(QgsProcessingAlgorithm):
processing.run("otb:BandMathX", BMX_parameters, context=context, feedback=feedback)
os.remove(os.path.join(output_folder,"outcontext.txt"))
maskc = os.path.join(tmp_folder, prefix+"mask_clip.tif")
processing.run("otb:Rasterization", {"in":clip,"im":Smooth_TS,"mode.binary.foreground":1,"out":maskc, "outputpixeltype":0}, context=context, feedback=feedback)
vald = os.path.join(tmp_folder, prefix+"valid.tif")
ND_app_parameters = {"in": TS_file, "out":vald, "mode":"buildmask", 'mode.apply.mask':maskc, "outputpixeltype":0}
processing.run('otb:ManageNoData', ND_app_parameters, context=context, feedback=feedback)
mask = os.path.join(tmp_folder, prefix+"mask.tif")
processing.run("otb:Rasterization", {"in":clip,"im":Smooth_TS,"mode.binary.foreground":1,"out":mask, "outputpixeltype":0}, context=context, feedback=feedback)
BMX_parameters = {'il': [maskc, vald], 'exp':'im1b1*im2b1', 'out':mask, 'outputpixeltype':0, 'outcontext':os.path.join(output_folder,"outcontext.txt")}
processing.run("otb:BandMathX", BMX_parameters, context=context, feedback=feedback)
os.remove(os.path.join(output_folder,"outcontext.txt"))
LS_Strat = os.path.join(tmp_folder, prefix+"LandStrat_metric.tif")
LS_app_parameters={"ndvits":Moy_TS, "out": LS_Strat, "outputpixeltype":5}
......@@ -444,11 +453,11 @@ class LandscapeStratification(QgsProcessingAlgorithm):
LS_Strat_norm = os.path.join(tmp_folder, prefix+"LandStrat_metric_norm.tif")
DC_app_parameters={"in":LS_Strat, "out":LS_Strat_norm, "outmin":0, "outmax":2048, "outputpixeltype":2}
processing.run("otb:DynamicConvert", DC_app_parameters, context=context, feedback=feedback)
#setNoDataValue(LS_Strat_norm,-9999)
NDoutput = os.path.join(tmp_folder,prefix+"LandStrat_metric_norm_masked.tif")
ND_app_parameters = {'in': LS_Strat_norm, 'out':NDoutput, 'mode':'apply', 'mode.apply.mask':mask, 'mode.apply.ndval':-9999, 'outputpixeltype':2}
ND_app_parameters = {'in': LS_Strat_norm, 'out':NDoutput, 'mode':'apply', 'mode.apply.mask':mask, 'outputpixeltype':2}
processing.run('otb:ManageNoData', ND_app_parameters, context=context, feedback=feedback)
setNoDataValue(NDoutput,-9999)
LS_Strat = NDoutput
GRM_output = os.path.join(tmp_folder,prefix+"LandStrat_map.tif")
......
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