TrainImageClassifier: All classes are empty

Hello!

I was searching throught the Internet, but did not find a solution to the error:

(WARNING): file ..\Modules\Learning\Sampling\src\otbSamplingRateCalculatorList.cxx, line 99, SamplingRateCalculatorList (00000283DDC3C0E0): All classes are empty !
(FATAL) TrainImagesClassifier: No samples found in the inputs!

I’ve got a .TIFF aerial image and a .SHP layer with polygons. Some recommendations were to switch off Editing Mode to save the features. But even after that, the error is still here.
Could you assist?
Thank you!

Dear @HardRock4Life,
Thank you for using OTB.
Could you tell us how you run the TranImagesClassifier?
Is it from the command line? In this case, could you share with us the command you wrote?
Or are you using the QGIS plugin? In this case, could you share screenshots of the interface?
Sincerely.

Hello @julienosman,
I do everything via QGIS.

So, here are the screenshots of the Classifier interface:

I tried to follow the steps from this video
OTB & QGIS : A powerful wedding - YouTube

I could not embed all the three images, because the forum rules are that new users cannot embed more than 1 media item in a single message

Let me know if you need some additional info.

Since you are using the SVM classfication, which is a supervised classification, you need to provide the labels (ground truth).
In the input vector data, one of the field needs to contains the labels of the classes. You have to write the name of this field in “Field containing the class integer label for supervision”.

Yep, I’ve corrected it and now here is the error I had ran into I had described:

  1. Your input vector data may be empty. Consider checking it with QGIS.
  2. If the input vector data doesn’t overlaps with the input image, the algo won’t find any sample. You may want to check that too, by opening both the image and the vector in QGIS.
  1. I’ve got a attribute table in QGIS here:

This is how vector data and the input image are seen in the QGIS map window.
Is this what you mean overlapping?

1 Like

Let’s put it otherwise - could you recommend some examples projects where TIFF and SHP are the inputs so I could run them and understand how things should be?

You can look at the example provided in the documentation. The input image can be found here, and the shape file here here here and here.

1 Like

Okay, it seems to be working. Let’s see if I can do it more accurate.
Thank you for your support!

1 Like

One last thing - is there any article where I can read the algorithm’s process, like, how it works under the hood, any formulas etc.?

Well, it depends on the learning algorithm you chose with the -classifier parameter. The default is to use the support-vector machin (SVM). But others are available, see the documentation for the list. You will also find links to the implementations, which usually contain more details on the algorithms.

1 Like