Train Support Vector Machine Classifier Image Analyst

TrainSupportVectorMachineClassifier(in_raster, in_training_features, out_classifier_definition, {in_additional_raster}, {max_samples_per_class}, {used_attributes}, {dimension_value_field})

NameExplanationData TypeThe raster dataset to classify.

The preferred input is a 3-band, 8-bit segmented raster dataset in which 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 Layer; Mosaic Layer; Image Service; StringThe training sample file or layer that delineates the training sites.

These can be either shapefiles or feature classes that contain the training samples. The following field names are required in the training sample file:

* classname—A text field indicating the name of the class category
* classvalue—A long integer field containing the integer value for each class category

Feature Layerout_classifier_definition

The output JSON format file that will contain attribute information, statistics, hyperplane vectors, and other information for the classifier. An .ecd file will be created.

FileAncillary raster datasets, such as a multispectral image or a DEM, will be incorporated to generate attributes and other required information for classification. This parameter is optional.

Raster Layer; Mosaic Layer; Image Service; StringThe maximum number of samples that will be used to define each class.

The default value of 500 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,…]

Specifies the attributes that will be included in the attribute table associated with the output raster.

*
* COLOR—The RGB color values will be derived from the input raster on a per-segment basis. This is also known as average chromaticity color.
* MEAN—The average digital number (DN) will be derived from the optional pixel image on a per-segment basis.
* STD—The standard deviation will be derived from the optional pixel image on a per-segment basis.
* COUNT—The number of pixels composing the segment, on a per-segment basis.
* COMPACTNESS—The degree to which a segment is compact or circular, on a per-segment basis. The values range from 0 to 1, in which 1 is a circle.
* RECTANGULARITY—The degree to which the segment is rectangular, on a per-segment basis. The values range from 0 to 1, in which 1 is a rectangle.

This parameter is only enabled if the Segmented key property is set to true on the input raster. If the only input to the tool is a segmented image, the default attributes are COLOR, COUNT, COMPACTNESS, and RECTANGULARITY. If an in_additional_raster value is included as an input with a segmented image, MEAN and STD are also available attributes.

StringContains dimension values in the input training sample feature class.

This parameter is required to classify a time series of raster data using the change analysis raster output from the Analyze Changes Using CCDC tool.

FieldCode sample
TrainSupportVectorMachineClassifier example 1 (Python window)This Python example uses the SVM classifier to classify a segmented raster.

import arcpy
from arcpy.ia import *
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension(“ImageAnalyst”)
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”)

TrainSupportVectorMachineClassifier example 2 (stand-alone script)This Python script uses the SVM classifier to classify a segmented raster.

# Import system modules
import arcpy
from arcpy.ia import *
“”” ‘TrainSupportVectorMachineClassifier(in_raster, in_training_features, out_classifier_definition, {in_additional_raster}, {max_num_samples_per_class}, {used_attributes})
“””
# 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 Image Analyst extension license
arcpy.CheckOutExtension(“ImageAnalyst”)
#Execute
TrainSupportVectorMachineClassifier(inSegRaster, train_features, out_definition, in_additional_raster, maxNumSamples, attributes)

TrainSupportVectorMachineClassifier example 3 (stand-alone script)This Python script uses the SVM classifier to classify a time series multidimensional raster using the output from the Analyze Changes Using CCDC tool.

# Import system modules
import arcpy
from arcpy.ia import *
# Check out the ArcGIS Image Analyst extension license
arcpy.CheckOutExtension(“ImageAnalyst”)
# Define input parameters
in_changeAnalysisRaster = “c:/test/LandsatCCDC.crf”
train_features = “c:/test/train.gdb/train_features”
out_definition = “c:/output/change_detection.ecd”
additional_raster = ”
attributes = None
dimension_field = “DateTime”
# Execute
arcpy.ia.TrainSupportVectorMachineClassifier(
in_changeAnalysisRaster, train_features, out_definition,
additional_raster, attributes, dimension_field)