Supervised classification with OTB using WKT polygons for training

I am just getting started with OTB on Python and would like to begin with supervised classification of Sentinel-2 scenes.

For training the classifier I would like to use WKT polygons. However, I don’t find enough code examples and documentation for the OTB applications like classification in my case.

Looking forward to some help in this regards.

AM

Hello,

have you read this tutorial in the OTB Cookbook ? I think this is a good starting point for classification using OTB.

Cédric

Is there a table where all the applications (along with the keys for their parameters) of the OTB are listed?

As a first time user it is difficult to imagine the structure since for each applications there are several keys and these keys have different formats of passing a value like window size for a filter.

Hi Arnab,

You can have a look at the list of applications here, but to know their parameters, you have to read their documentation.
To start with landcover classification with OTB, as Cédric said, you should read the corresponding recipe in the CookBook.

And if you are using OTB from Python, you should read this page in the CookBook.

Then, if you want to get some examples of running a Sentinel-2 classification from Python, you could have a look at these jupyter notebooks. They are quite simple but can help you to start with OTB.

Best regards,

Yannick

I have had a look at these pages but the information is not comprehensive.

I am not sure why but I can get the parameters keys for certain applications but some are not working.

For example,
app = otbApplication.Registry.CreateApplication(“Smoothing”)

gives me the available applications when I “print (app.GetParametersKeys())”

but
app = otbApplication.Registry.CreateApplication(“TrainImagesClassifier”)
print (app.GetParametersKeys())

returns me “AttributeError: ‘NoneType’ object has no attribute ‘GetParametersKeys’”

So if it works for one application it should work for all?
I don’t understand this selective behavior.

Hello, if

app = otbApplication.Registry.CreateApplication(“TrainImagesClassifier”)

returns None this means that the application has not been successfully created. Can you try:

otbApplication.Registry.GetAvailableApplications()

This should return the list of registered otb applications. Can you find `TrainImagesClassifier in it ?

I have checked this before and “otbApplication.Registry.GetAvailableApplications()” doesn’t return the ‘TrainImagesClassifier’.

It fails to load due to the following reason,
“Failed to load libraries from /home/anaconda3/envs/snow/lib/otb/applications/otbapp_TrainImagesClassifier.so while trying to create application TrainImagesClassifier
because: -> libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory”

However, I can see this application when I search for it,

It seems that OTB looks for the applications in /home/anaconda3/envs/snow/lib/otb/applications when they actually are in /anaconda3/envs/snow/lib/otb/applications

How have you configured OTB_APPLICATION_PATH ?

I haven’t configured any path.
“otb” is one of the libraries in my library that I install while creating my environment.
Here is where the missing package is located,