Commit 3597a3b6 authored by Manuel Grizonnet's avatar Manuel Grizonnet

ENH: solutions of python exercises run without error

parent ae6b42a3
......@@ -323,9 +323,10 @@ ExtractROI.STARTX=140
2. Open ~exercise1.py~ and complete the "FILL THE GAP 1".
You need to complete the path of ~app-python/images~ of your system.
3. Open ~exercise1.py~ and complete the "FILL THE GAP 2".
You need to initialize the Superimpose OTB application. See that the ~inr~
,~inm~ and ~out~ parameters are already set.
4. Launch ~exercise1.py~ the script with the command
You need to initialize the Superimpose OTB application.
4. Open ~exercise1.py~ and complete the "FILL THE GAP 3" to set ~inr~
,~inm~ and ~out~ parameters of the Superimpose application.
5. Launch ~exercise1.py~ the script with the command
python exercise1.py. How does the output file ~B8A_10m.tif~ look like?
......@@ -344,9 +345,8 @@ ExtractROI.STARTX=140
using Red band (B4) and NIR band (B8A) from the S2 product:
1. Open ~exercise2.py~ and complete the "FILL THE GAP 1".
You need to complete the path of ~app-python/images~ of your system.
2. Open ~exercise2.py~ and complete the "FILL THE GAP" 2, 3 and 4.
2. Open ~exercise2.py~ and complete the "FILL THE GAP" 2 and 3.
You need to :
- configure the application1 "Superimpose" parameters : ~inr,imr,out~
- configure the application2 "BandMath" parameters: ~il,out,exp~
- configure the application3 "BandMath" parameters: ~il,out,exp~
*Note:* Take a look to lines 23-30 to understand the filepath of each band image.
......
......@@ -295,9 +295,8 @@ ExtractROI.STARTX=140
du produit Sentinel-2:
1. Ouvrez ~exercise2.py~ et compléter la ligne "FILL THE GAP 1".
Vous devez adapter le chemin ~app-python/images~ à votre système.
2. Ouvrez ~exercise2.py~ et compléter le champ "FILL THE GAP" 2, 3 and 4.
2. Ouvrez ~exercise2.py~ et compléter le champ "FILL THE GAP" 2 and 3.
Vous devez :
- configurer *application1* (Superimpose) et les paramètres : ~inr,imr,out~
- configurer *application2* (BandMath) et les paramètres: ~il,out,exp~
- configurer *application3* (BandMath et les paramètres: ~il,out,exp~
*Note:* Etudiez les lignes 23-30 pour comprendre quel est le chemin de
......@@ -631,11 +630,11 @@ ExtractROI.STARTX=140
3. L'application de calcul de la matrice de confusion permet de comparer les images :
#+BEGIN_EXAMPLE
$ otbcli_ComputeConfusionMatrix -in GSW_10.tif \
$ otbcli_ComputeConfusionMatrix -in water_mask_SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4.tif \
-nodatalabel 255 \
-ref raster \
-ref.raster.in water_mask_SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4.tif \
-ref.raster.nodata "255" \
-out conf_A_90.csv
-ref.raster.in GSW_10.tif \
-out conf_20170407_10.csv
#+END_EXAMPLE
The best kappa results for each date are:
......
......@@ -50,11 +50,18 @@ if __name__ == "__main__":
###############
# The following lines set the necessary application parameters:
Superimpose.SetParameterString("inr",str( d["input_path"] + d["B4_image"]))
Superimpose.SetParameterString("inm",str( d["input_path"] + d["B8A_image"]))
Superimpose.SetParameterString("out", "B8A_10m.tif")
# ---
# FILL THE GAP 3 : Complete the input and output parameters
#
# Example:
#
#Superimpose.SetParameterString("inr",str( d["input_path"] + d["????"]))
#Superimpose.SetParameterString("inm",str( d["input_path"] + d["????"]))
#Superimpose.SetParameterString("out", "????.tif")
#
# END OF GAP
# ---
# The following line execute the application
Superimpose.ExecuteAndWriteOutput()
......
......@@ -40,17 +40,9 @@ if __name__ == "__main__":
# The following line creates an instance of the Superimpose application
application1 = otbApplication.Registry.CreateApplication("Superimpose")
# ---
# FILL THE GAP 2 : Complete the input and output parameters
#
# Example:
#
#application1.SetParameterString("inr",str( d["input_path"] + d["????"]))
#application1.SetParameterString("inm",str( d["input_path"] + d["????"]))
#application1.SetParameterString("out", "????.tif")
#
# END OF GAP
# ---
application1.SetParameterString("inr",str( d["input_path"] + d["B4_image"]))
application1.SetParameterString("inm",str( d["input_path"] + d["B8A_image"]))
application1.SetParameterString("out", "B8A_10m.tif")
print("Launching... Resampling")
# The following line execute the application
......@@ -65,7 +57,7 @@ if __name__ == "__main__":
# ---
# FILL THE GAP 3 : Complete the input and output parameters of the BandMath
# FILL THE GAP 2 : Complete the input and output parameters of the BandMath
#
# Example:
#application2.SetParameterStringList("il",["????.tif", str(d["input_path"] + d["?????"])])
......@@ -85,7 +77,7 @@ if __name__ == "__main__":
application3 = otbApplication.Registry.CreateApplication("BandMath")
# ---
# FILL THE GAP 4 : Complete the input and output parameters of the BandMath
# FILL THE GAP 3 : Complete the input and output parameters of the BandMath
#
# Exemple:
#application3.SetParameterStringList("il",["????.tif"])
......
#! /usr/bin/python
from sys import exit
import otbApplication
if __name__ == "__main__":
......@@ -22,6 +23,9 @@ if __name__ == "__main__":
# END OF GAP
###############
if not "dataset_folder" in d:
exit("Your data folder (\'d[\"dataset_folder\"]\') is not set.")
d["image_name"] = "SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4"
d["input_path"] = d["dataset_folder"] + "/" + d["image_name"] +"/"
d["B3_image"] = d["image_name"] + "_FRE_B3.tif"
......@@ -50,11 +54,18 @@ if __name__ == "__main__":
###############
# The following lines set the necessary application parameters:
# ---
# FILL THE GAP 3 : Complete the input and output parameters
#
# Example:
#
Superimpose.SetParameterString("inr",str( d["input_path"] + d["B4_image"]))
Superimpose.SetParameterString("inm",str( d["input_path"] + d["B8A_image"]))
Superimpose.SetParameterString("out", "B8A_10m.tif")
#
# END OF GAP
# ---
# The following line execute the application
Superimpose.ExecuteAndWriteOutput()
......
#! /usr/bin/python
from sys import exit
import otbApplication
......@@ -21,6 +22,9 @@ if __name__ == "__main__":
# END OF GAP
# ---
if not "dataset_folder" in d:
exit("Your data folder (\'d[\"dataset_folder\"]\') is not set.")
d["image_name"] = "SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4"
d["input_path"] = d["dataset_folder"] + "/" + d["image_name"] +"/"
d["B3_image"] = d["image_name"] + "_FRE_B3.tif"
......@@ -37,21 +41,10 @@ if __name__ == "__main__":
#
# The following line creates an instance of the Superimpose application
application1 = otbApplication.Registry.CreateApplication("Superimpose")
# ---
# FILL THE GAP 2 : Complete the input and output parameters
#
# Exemple:
#
#application1.SetParameterString("inr",str( d["input_path"] + d["????"]))
#application1.SetParameterString("inm",str( d["input_path"] + d["????"]))
#application1.SetParameterString("out", "????.tif")
application1.SetParameterString("inr",str( d["input_path"] + d["B4_image"]))
application1.SetParameterString("inm",str( d["input_path"] + d["B8A_image"]))
application1.SetParameterString("out", "B8A_10.tif")
#
# END OF GAP
# ---
print "Launching... Resampling"
# The following line execute the application
......@@ -66,7 +59,7 @@ if __name__ == "__main__":
# ---
# FILL THE GAP 3 : Complete the input and output parameters of the BandMath
# FILL THE GAP 2 : Complete the input and output parameters of the BandMath
#
# Example:
#application2.SetParameterStringList("il",["????.tif", str(d["input_path"] + d["?????"])])
......@@ -90,7 +83,7 @@ if __name__ == "__main__":
application3 = otbApplication.Registry.CreateApplication("BandMath")
# ---
# FILL THE GAP 4 : Complete the input and output parameters of the BandMath
# FILL THE GAP 3 : Complete the input and output parameters of the BandMath
#
# Exemple:
#application3.SetParameterStringList("il",["????.tif"])
......
#! /usr/bin/python
from sys import exit
import otbApplication
......@@ -21,6 +22,9 @@ if __name__ == "__main__":
# END OF GAP
# ---
if not "dataset_folder" in d:
exit("Your data folder (\'d[\"dataset_folder\"]\') is not set.")
d["image_name"] = "SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4"
d["input_path"] = d["dataset_folder"] + "/" + d["image_name"] +"/"
d["B3_image"] = d["image_name"] + "_FRE_B3.tif"
......
#! /usr/bin/python
from sys import argv
from sys import exit,argv
import otbApplication
......@@ -24,6 +24,10 @@ if __name__ == "__main__":
d["image_name"] = argv[1]
else:
d["image_name"] = "SENTINEL2A_20170407-154054-255_L2A_T17MNP_D_V1-4"
if not "dataset_folder" in d:
exit("Your data folder (\'d[\"dataset_folder\"]\') is not set.")
d["input_path"] = d["dataset_folder"] + "/" + d["image_name"] +"/"
d["B3_image"] = d["image_name"] + "_FRE_B3.tif"
d["B4_image"] = d["image_name"] + "_FRE_B4.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