Commit 88609d3c authored by Lozac'h Loic's avatar Lozac'h Loic

ADD:SoilMoisturePipeline.py csvtomoist pipeline

parent 98db5844
......@@ -386,7 +386,43 @@ def get_model4invertion():
print("Error : Can't find date in modelchoice file for sar :"+os.path.basename(sarvv))
exit()
def csvtoraster_pipeline(csv,outmoist):
app1 = otbApplication.Registry.CreateApplication("ApplyCsvLabelsFile")
# The following lines set all the application parameters:
app1.SetParameterString("incsv", csv)
app1.SetParameterString("inlabels", maskedlabels)
app1.SetParameterString("out", "temp1.tif")
print("Launching... Resampling")
# The following line execute the application
app1.Execute() #ExecuteAndWriteOutput()
print("End of Resampling \n")
app6 = otbApplication.Registry.CreateApplication("BandMath")
app6.AddImageToParameterInputImageList("il",app1.GetParameterOutputImage("out"))
app6.SetParameterString("out", "temp2.tif")
app6.SetParameterString("exp", "im1b1*5")
print("Launching... BandMath(im1b1*5)")
# The following line execute the application
app6.Execute() #ExecuteAndWriteOutput()
print("End of BandMath \n")
# Ajouter ManageNoData
app7 = otbApplication.Registry.CreateApplication("ManageNoData")
app7.SetParameterInputImage("in", app6.GetParameterOutputImage("out"))
app7.SetParameterString("out", outmoist+"?gdal:co:COMPRESS=DEFLATE&gdal:co:BIGTIFF=YES")#
app7.SetParameterOutputImagePixelType("out", otbApplication.ImagePixelType_uint8)
app7.SetParameterString("mode", "changevalue")
print("Launching... ManageNoData")
app7.ExecuteAndWriteOutput()
print("Done \n")
def short_pipeline(intersectionEnv):
global slopevalue
......@@ -792,9 +828,15 @@ if __name__ == "__main__":
list_parser.add_argument('-outtxt', action='store', required=True, help='Output text file where each Sentinel-1 dates correspond their model dry or wet to use')
list_parser.add_argument('--no-resampling', dest='resampling', action='store_false', help='[Optional] Resample GPM 100km to 10m, default false')
list_parser.set_defaults(resampling=False)
args=parser.parse_args()
# Apply CSV file on Labels file
list_parser = subparsers.add_parser('csvtomoist', help="Apply CSV results on labels raster to create moisture map")
list_parser.add_argument('-csvdir', action='store', required=True, help='Directory to find all the NDVI file to stack. Files naming must contain "NDVI" and ".tif" extension')
list_parser.add_argument('-maskedlabels', action='store', required=True, help='Masked segmented image computed from NDVI')
list_parser.add_argument('-outdir', action='store', required=True, help='Output directory')
args=parser.parse_args()
if args.pipeline == 'short' :
modeldir = args.modeldir
......@@ -859,6 +901,24 @@ if __name__ == "__main__":
outformat = args.outformat
print("Starting Segment vector pipeline")
labels_vector_pipeline()
elif args.pipeline == 'csvtomoist' :
maskedlabels = args.maskedlabels
if not os.path.isdir(args.csvdir):
print("erreur "+args.csvdir+" n'est pas un dossier")
exit()
if not os.path.exists(args.outdir):
os.mkdir(args.outdir)
csvs=search_files(args.csvdir, 'MV', 'csv', 'f')
if len(csvs)==0 :
print("No CSV file found.")
exit()
for csv in csvs:
outmoist = os.path.join(args.outdir,os.path.basename(csv)[:-3]+"TIF")
print("\nProcessing file: "+csv)
csvtoraster_pipeline(csv,outmoist)
elif args.pipeline == 'serie' :
......
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