Summary
Generate an Esri classifier definition (.ecd) file using the Support Vector Machine (SVM) classification definition.
Usage
The SVM classifier provides a powerful, modern supervised classification method that is able to handle a segmented raster input, or a standard image. This is a relatively new classification method that is widely used among researchers.
For standard image inputs, the tool accepts multiple-band imagery with any bit depth, and it will perform the SVM classification on a pixel basis, based on the input training feature file.
For segmented rasters, which have their key property set to Segmented, the tool computes the index image and associated segment attributes from the RGB segmented raster. The attributes are computed to generate the classifier definition file to be used in a separate classification tool. The attributes for each segment can be computed from any Esri-supported image.
There are several advantages with the SVM classifier tool, as opposed to the traditional classification methods:
- The SVM classifier can handle very large segmented images, whose attribute table can become quite large, which is especially helpful with high-resolution imagery.
- It is less susceptible to noise, correlated bands, and an unbalanced number or size of training sites within each class.
Any Esri-supported raster is accepted as input, including raster products, segmented raster, mosaics, image services, or generic raster datasets. Segmented rasters must be 8-bit rasters with 3-bands.
Segment Attributes is enabled only if one of the raster layer inputs is a segmented image.
Syntax
TrainSupportVectorMachineClassifier (in_raster, in_training_features, out_classifier_definition, {in_additional_raster}, {max_samples_per_class}, {used_attributes})
Parameter | Explanation | Data Type |
in_raster | Select the raster dataset you want to classify. The preferred input is a 3-band, 8-bit segmented raster dataset, where all the pixels in the same segment have the same color. The input can also be a 1-band 8-bit grayscale segmented raster. If no segmented raster is available, you can use any Esri-supported raster dataset. | Raster Dataset | Mosaic Dataset | Raster Layer | Mosaic Layer | Image Service Layer |
in_training_features | The training sample feature class must have been created in ArcMap. There is no method to create them in Python. | Feature Layer | Raster Catalog Layer |
out_classifier_definition | This is a JSON file that contains attribute information, statistics, hyperplane vectors and other information needed for the classifier. A file with an .ecd extension is created. | File |
in_additional_raster (Optional) | Optionally incorporate ancillary raster datasets, such as a segmented image, a multispectral image, or a DEM, to generate attributes and other required information for classification. | Raster Dataset | Mosaic Dataset | Raster Layer | Mosaic Layer | Image Service Layer |
max_samples_per_class (Optional) | The maximum number of samples to use for defining each class. The default value of 100 is recommended when the inputs are nonsegmented rasters. A value that is less than or equal to 0 means that the system will use all the samples from the training sites, to train the classifier. | Long |
used_attributes used_attributes;used_attributes (Optional) | Specify the attributes to be included in the attribute table associated with the output raster. This parameter is only enabled if the SEGMENTED key property is set to true on the input raster. If the only input into the tool is a segmented image, the default attributes are COLOR, COUNT, COMPACTNESS, and RECTANGULARITY. If an in_additional_raster is also included as an input along with a segmented image, then MEAN and STD are available as options.
| String |
Code Sample
TrainSupportVectorClassifier example 1 (Python window)
This Python example uses the SVM classifier to classify a segmented raster.
import arcpy
from arcpy.sa import *
arcpy.gp.TrainSupportVectorMachineClassifier(
"c:/test/moncton_seg.tif", "c:/test/train.gdb/train_features",
"c:/output/moncton_sig_SVM.ecd", "c:/test/moncton.tif", "10",
"COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY")
TrainSupportVectorClassifier example 2 (stand-alone script)
This Python script uses the SVM classifier to classify a segmented raster.
# Import system modules
import arcpy
from arcpy.sa import *
# Set local variables
inSegRaster = "c:/test/moncton_seg.tif"
train_features = "c:/test/train.gdb/train_features"
out_definition = "c:/output/moncton_sig.ecd"
in_additional_raster = "c:/moncton.tif"
maxNumSamples = "10"
attributes = "COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
#Execute
arcpy.gp.TrainSupportVectorMachineClassifier(
inSegRaster, train_features, out_definition,
in_additional_raster, maxNumSamples, attributes)
Environments
Licensing Information
- ArcGIS for Desktop Basic: Requires Spatial Analyst
- ArcGIS for Desktop Standard: Requires Spatial Analyst
- ArcGIS for Desktop Advanced: Requires Spatial Analyst