OGRLayerClassifier

Classify an OGR layer based on a machine learning model and a list of features to consider.

Description

This application will apply a trained machine learning model on the selected feature to get a classification of each geometry contained in an OGR layer. The list of feature must match the list used for training. The predicted label is written in the user defined field for each geometry.

This application has several output images and supports “multi-writing”. Instead of computing and writing each image independently, the streamed image blocks are written in a synchronous way for each output. The output images will be computed strip by strip, using the available RAM to compute the strip size, and a user defined streaming mode can be specified using the streaming extended filenames (type, mode and value). Note that multi-writing can be disabled using the multi-write extended filename option: &multiwrite=false, in this case the output images will be written one by one. Note that multi-writing is not supported for MPI writers.

Parameters

Name of the input shapefile -inshp vectorfile Mandatory
Name of the input shapefile

XML file containing mean and variance of each feature -instats filename [dtype] Mandatory
XML file containing mean and variance of each feature.

Input model filename -insvm filename [dtype] Mandatory
Input model filename.

Features -feat string1 string2...
Features to be calculated

Field containing the predicted class -cfield string Default value: predicted
Field containing the predicted class

Examples

From the command-line:

otbcli_OGRLayerClassifier -inshp vectorData.shp -instats meanVar.xml -insvm svmModel.svm -feat perimeter -cfield predicted

From Python:

import otbApplication

app = otbApplication.Registry.CreateApplication("OGRLayerClassifier")

app.SetParameterString("inshp", "vectorData.shp")
app.SetParameterString("instats", "meanVar.xml")
app.SetParameterString("insvm", "svmModel.svm")
app.SetParameterStringList("feat", "perimeter")
app.SetParameterString("cfield", "predicted")

app.ExecuteAndWriteOutput()

Limitations

Experimental. Only shapefiles are supported for now.