Train Maximum Likelihood Classifier (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Generates an Esri classifier definition file (.ecd) 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.

  • The Output Classifier Definition File contains attribute statistics suitable for the Maximum Likelihood Classification tool.

  • The Segment Attributes parameter is only active if one of the raster layer inputs is a segmented image.

  • A two step process is necessary to classify time series raster data using the Continuous Change Detection and Classification (CCDC) algorithm. First, run the Analyze Changes Using CCDC tool, which is available with an Image Analyst extension license. Next, use those results as input to this training tool.

    The training sample data must have been collected at multiple times using the Training Samples Manager. The dimension value for each sample is listed in a field in the training sample feature class, which is specified in the Dimension Value Field parameter.

Parameters

LabelExplanationData Type
Input Raster

The raster dataset to classify.

Raster Layer; Mosaic Layer; Image Service; String
Output Classifier Definition File

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.

File
Additional Input Raster
(Optional)

Incorporates ancillary raster datasets, such as a segmented image or DEM. This parameter is optional.

Raster Layer; Mosaic Layer; Image Service; String
Segment Attributes Used
(Optional)

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

  • COLORThe RGB color values will be derived from the input raster on a per-segment basis. This is also known as average chromaticity color.
  • MEANThe average digital number (DN) will be derived from the optional pixel image on a per-segment basis.
  • STDThe standard deviation will be derived from the optional pixel image on a per-segment basis.
  • COUNTThe number of pixels composing the segment, on a per-segment basis.
  • COMPACTNESSThe 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.
  • RECTANGULARITYThe 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.
String
Dimension Value Field
(Optional)

Contains 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 in the Image Analyst toolbox.

Field

TrainMaximumLikelihoodClassifier(in_raster, out_classifier_definition, {in_additional_raster}, {used_attributes}, {dimension_value_field})
NameExplanationData Type
in_raster

The raster dataset to classify.

Raster Layer; Mosaic Layer; Image Service; String
out_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.

File
in_additional_raster
(Optional)

Incorporates ancillary raster datasets, such as a segmented image or DEM. This parameter is optional.

Raster Layer; Mosaic Layer; Image Service; String
used_attributes
[used_attributes,...]
(Optional)

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

  • COLORThe RGB color values will be derived from the input raster on a per-segment basis. This is also known as average chromaticity color.
  • MEANThe average digital number (DN) will be derived from the optional pixel image on a per-segment basis.
  • STDThe standard deviation will be derived from the optional pixel image on a per-segment basis.
  • COUNTThe number of pixels composing the segment, on a per-segment basis.
  • COMPACTNESSThe 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.
  • RECTANGULARITYThe 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.

String
dimension_value_field
(Optional)

Contains 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 in the Image Analyst toolbox.

Field

Code sample

TrainMaximumLikelihoodClassifier example 1 (Python window)

The following Python window script demonstrates how to use the TrainMaximumLikelihoodClassifier 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"

# Execute 
TrainMaximumLikelihoodClassifier(inSegRaster, train_features, out_definition, 
                                 in_additional_raster, attributes)
TrainMaximumLikelihoodClassifier example 3 (stand-alone script)

This example shows how to train a maximum likelihood classifier using a change analysis raster from the Analyze Changes Using CCDC tool.

# Import system modules
import arcpy
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")


# Set local variables
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.sa.TrainMaximumLikelihoodClassifier(
	in_changeAnalysisRaster, train_features, out_definition,
	additional_raster, attributes, dimension_field)

Related topics