VectorClassifier - Vector Classification¶
Performs a classification of the input vector data according to a model file.
This application performs a vector data classification based on a model file produced by the TrainVectorClassifier application.Features of the vector data output will contain the class labels decided by the classifier (maximal class label = 65535). There are two modes: 1) Update mode: add of the ‘cfield’ field containing the predicted class in the input file. 2) Write mode: copies the existing fields of the input file in the output file and add the ‘cfield’ field containing the predicted class. If you have declared the output file, the write mode applies. Otherwise, the input file update mode will be applied.
This section describes in details the parameters available for this application. Table  presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is VectorClassifier .
|||Table: Parameters table for Vector Classification.|
|Parameter Key||Parameter Name||Parameter Type|
|in||Name of the input vector data||Input vector data|
|instat||Statistics file||Input File name|
|model||Model file||Input File name|
|feat||Field names to be calculated.||List|
|out||Output vector data file containing class labels||Output File name|
|inxml||Load otb application from xml file||XML input parameters file|
|outxml||Save otb application to xml file||XML output parameters file|
- Name of the input vector data: The input vector data file to classify.
- Statistics file: A XML file containing mean and standard deviation to centerand reduce samples before classification, produced by ComputeImagesStatistics application.
- Model file: Model file produced by TrainVectorClassifier application.
- Field class: Field containing the predicted class.Only geometries with this field available will be taken into account. The field is added either in the input file (if ‘out’ off) or in the output file. Caution, the ‘cfield’ must not exist in the input file if you are updating the file.
- Field names to be calculated.: List of field names in the input vector data used as features for training. Put the same field names as the TrainVectorClassifier application.
- Confidence map: Confidence map of the produced classification. The confidence index depends on the model : - LibSVM : difference between the two highest probabilities (needs a model with probability estimates, so that classes probabilities can be computed for each sample) - OpenCV * Boost : sum of votes * DecisionTree : (not supported) * GradientBoostedTree : (not supported) * KNearestNeighbors : number of neighbors with the same label * NeuralNetwork : difference between the two highest responses * NormalBayes : (not supported) * RandomForest : Confidence (proportion of votes for the majority class). Margin (normalized difference of the votes of the 2 majority classes) is not available for now. * SVM : distance to margin (only works for 2-class models). .
- Output vector data file containing class labels: Output vector data file storing sample values (OGR format).If not given, the input vector data file is updated.
- Load otb application from xml file: Load otb application from xml file.
- Save otb application to xml file: Save otb application to xml file.
To run this example in command-line, use the following:
otbcli_VectorClassifier -in vectorData.shp -instat meanVar.xml -model svmModel.svm -out vectorDataLabeledVector.shp -feat perimeter area width -cfield predicted
To run this example from Python, use the following code snippet:
#!/usr/bin/python # Import the otb applications package import otbApplication # The following line creates an instance of the VectorClassifier application VectorClassifier = otbApplication.Registry.CreateApplication("VectorClassifier") # The following lines set all the application parameters: VectorClassifier.SetParameterString("in", "vectorData.shp") VectorClassifier.SetParameterString("instat", "meanVar.xml") VectorClassifier.SetParameterString("model", "svmModel.svm") VectorClassifier.SetParameterString("out", "vectorDataLabeledVector.shp") # The following line execute the application VectorClassifier.ExecuteAndWriteOutput()
Shapefiles are supported. But the SQLite format is only supported in update mode.
- These additional resources can be useful for further information: