Hello to all,
I'm new to OTB and trying to write a classification script
using python.
I have an itk Error while trying to run some
otbApplications. Specifically, when trying to run the
PolygonClassStatistics app, I get:
"exceptions.RuntimeError:Exception thrown in otbApplication
Application_SetParameterString:
C:\dashboard\otb\scr\Modules\Wrappers\Applicatio...:
itk::ERROR: ListViewParameter(00000000062DC770):
Cannot find cl"
I've doubled checked that my class field is called "cl".
Even if I run the PolygonClassStatistics GUI to extract the
statistics xml, and then try to run the SampleSelection app
with the xml I extracted before, I get another itk error:
"exceptions.RuntimeError:Exception thrown in otbApplication
Application_ExecuteAndWriteOutput:
C:\dashboard\otb\scr\Modules\Wrappers\Applicatio...:267:
itk::ERROR: Fatal error caught. Aborting..."
The RadiometricIndices app I run on my script works fine.
Thank you in advance
Regards,
Natalie
-------------------------
OS: Windows
10 64-bit OS
OTB version: OTB-contrib-5.10.1-win64
Scripter: PyScripter
My script is:
import sys
import os
import otbApplication
import numpy as np
import commands
#----------1. Polygon Class
Statistics------------------------------------------
# The following line creates an instance of the
PolygonClassStatistics application
PolygonClassStatistics =
otbApplication.Registry.CreateApplication('PolygonClassStatistics')
# We print the keys of all its parameter
print PolygonClassStatistics.GetParametersKeys()
# The following lines set all the application parameters:
# First, we set the input image filename
PolygonClassStatistics.SetParameterString("in",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Data\Dimou\2007\2007.tif")
# input vector filename
PolygonClassStatistics.SetParameterString("vec",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Files\Classifications\samptriad.shp")
#vector field name
PolygonClassStatistics.SetParameterString("field", 'cl')
# Set the output filename, using the algorithm to
differentiate the outputs
PolygonClassStatistics.SetParameterString("out",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Files\Classifications\1triadsamples.xml")
# This will execute the application and save the output
file
PolygonClassStatistics.ExecuteAndWriteOutput()
#----------2. Select
Samples----------------------------------------------------
# The following line creates an instance of the
SampleSelection application
SampleSelection =
otbApplication.Registry.CreateApplication("SampleSelection")
# The following lines set all the application parameters:
SampleSelection.SetParameterString("in",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Data\Dimou\2007\2007.tif")
SampleSelection.SetParameterString("vec",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Files\Classifications\samptriad.shp")
SampleSelection.SetParameterString("instats",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Files\Classifications\1triadsamples.xml")
SampleSelection.SetParameterString("out",
r"C:\Users\Natalie\Dropbox\ATM_auth_pgp\THESIS\Files\Classifications\2triadsampselect.shp")
# The following line execute the application
SampleSelection.ExecuteAndWriteOutput()
--