Available with Spatial Analyst license.
Summary
Generates an Esri classifier definition (.ecd) file using the Maximum Likelihood Classifier (MLC) classification definition.
Usage
To complete the maximum likelihood classification process, use the same input raster and the output .ecd file from this tool in the Classify Raster tool.
The input raster can be any Esri-supported raster with any valid bit depth.
To create a segmented raster dataset, use the Segment Mean Shift tool.
To create the training sample file, use the Training Sample Manager from the Image Classification toolbar. For information on how to use the Image Classification toolbar, see What is image classification?
The Output Classifier Definition File contains attribute statistics suitable for the Maximum Likelihood Classification tool.
The Segment Attributes parameter is enabled only if one of the raster layer inputs is a segmented image.
Syntax
TrainMaximumLikelihoodClassifier(in_raster, in_training_features, out_classifier_definition, {in_additional_raster}, {used_attributes})
Parameter | Explanation | Data Type |
in_raster | The raster dataset to classify. | Raster Layer; Mosaic Layer; Image Service; String |
in_training_features | The training sample file or layer that delineates your training sites. These can be either shapefiles or feature classes that contain your training samples. The following field names are required in the training sample file:
| Feature Layer; Raster Catalog Layer |
out_classifier_definition | The output JSON file that contains attribute information, statistics, hyperplane vectors, and other information for the classifier. An .ecd file is created. | File |
in_additional_raster (Optional) | Optionally incorporate ancillary raster datasets, such as a segmented image or DEM. | Raster Layer; Mosaic Layer; Image Service; String |
used_attributes [used_attributes,...] (Optional) | Specifies 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 to the tool is a segmented image, the default attributes are COLOR, COUNT, COMPACTNESS, and RECTANGULARITY. If an in_additional_raster is included as an input with a segmented image, MEAN and STD are also available attributes. | String |
Code sample
TrainMaximumLikelihoodClassifier example 1 (Python window)
The following Python window script demonstrates how to use this tool.
import arcpy
from arcpy.sa import *
TrainMaximumLikelihoodClassifier(
"c:/test/moncton_seg.tif", "c:/test/train.gdb/train_features",
"c:/output/moncton_sig.ecd", "c:/test/moncton.tif",
"COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY")
TrainMaximumLikelihoodClassifier example 2 (stand-alone script)
This example shows how to train a maximum likelihood classifier.
# 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"
attributes = "COLOR;MEAN;STD;COUNT;COMPACTNESS;RECTANGULARITY"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute
TrainMaximumLikelihoodClassifier(inSegRaster, train_features, out_definition,
in_additional_raster, attributes)
Environments
Licensing information
- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst