TrainVectorClassifier Error: Single selection mode is on, but there are 2 selected items

Hi there! I’m currently finding methods to conduct object-based image classification on QGIS. Before I used the TrainVectorClassifier Tool, I used the OTB segmentation tool, then the OTB zonal statistics tool, and then the QGIS join layer tool to eventually get my vector shapefile consisting of the objects and the sample points. When I tried to use the TrainVectorClassifier tool, after selecting the options as shown in the screenshot, I got the following error

(FATAL) TrainVectorClassifier: itk::ERROR: FieldParameter(000002657ADEBCE0): Single selection mode is on, but there are 2 selected items

My configuration and log panel is as follows:

Windows 10
OTB 8.0.1 (installed directly from website)
QGIS version: 3.22.6-Białowieża
QGIS code revision: b6f33b1a
Qt version: 5.15.2
Python version: 3.9.5
GDAL version: 3.4.2
GEOS version: 3.10.2-CAPI-1.16.0
PROJ version: Rel. 9.0.0, March 1st, 2022
PDAL version: 2.3.0 (git-version: 1c17a7)

Input parameters:

{ ‘io.vd’ : [‘C:/Users/adiba/Documents/local_GIS_exploration/Supervised_classification_local/joined_OTB_segmentation_stats_samples.gpkg’], ‘io.stats’ : ‘’, ‘io.out’ : ‘C:/Users/adiba/Documents/local_GIS_exploration/Supervised_classification_local/OTB_OBIA_MLC_trainedmodel.model’, ‘io.confmatout’ : ‘C:/Users/adiba/Documents/local_GIS_exploration/Supervised_classification_local/OTB_OBIA_MLC_trainedCM.csv’, ‘layer’ : 0, ‘feat’ : [‘mean_0’,‘stdev_0’,‘mean_1’,‘stdev_1’,‘mean_2’,‘stdev_2’,‘mean_3’,‘stdev_3’,‘mean_4’,‘stdev_4’,‘mean_5’,‘stdev_5’,‘mean_6’,‘stdev_6’,‘mean_7’,‘stdev_7’,‘mean_8’,‘stdev_8’,‘mean_9’,‘stdev_9’,‘mean_10’,‘stdev_10’,‘mean_11’,‘stdev_11’], ‘valid.vd’ : None, ‘valid.layer’ : 0, ‘cfield’ : ‘class id’, ‘v’ : True, ‘classifier’ : ‘bayes’, ‘rand’ : 0 }

2022-06-13 14:56:53 (FATAL) TrainVectorClassifier: itk::ERROR: FieldParameter(000002657ADEBCE0): Single selection mode is on, but there are 2 selected items

Execution completed in 0.31 seconds

When I searched online, it turned out that this was a syntax issue where the “Field Names for Training Features” option was not filled up properly in the textbox (ie in the bolded text above, the correct syntax is that there’s supposed to be no commas in between the parameters, according to this previous forum post Correct format for 'field names for training features' using TrainVectorClassifier - #15 by joaonaime ). However, after OTB 8, this textbox has been replaced by a multi-select window, hence there is no way for me to ‘edit’ my syntax to address the error. What should I do in this situation?

Dear @adibgeo,

Thank you for using OTB, and reporting this bug.

@troopa81 worked on replacing the textbox by a multi-select window to make the user experience more comfortable. He may have some ideas on how to fix this…

In the mean time, I don’t see any turnaround other than using the command line interface…

Regards.
Julien :slight_smile:

Thank you for the reply! I’m not well-versed in using the command line interface, do you have an example of a working script/ general steps to using it?

If you don’t feel at ease with command line interface, you can try the Mapla interface. It is a tiny graphical interface for OTB. You can find it in the installation directory ( mapla.bat). Double-click it, search for the TrainVectorClassifier application, and complete the fields.

1 Like

Thank you so much for the suggestion, it worked well (and quickly too)!

1 Like

With current Qgis master and OTB-8.0.1 for Linux I fail to reproduce the current issue. Could you please share with me a sample dataset and details how you configure your treatment ?

And What QGIS version do you use?

I ran into the same issue, and I solved it by simply making the field name a single word. e.g., if the field name is saved as a class ID, the algorithm will not run as spaces are not readable. To fix this, simply tie 2 or more words with an underscore, e.g., class_id.

This should work.

1 Like