Skip To Content

Train Maximum Likelihood Classifier

Available with Spatial Analyst license.

Available with Image Analyst license.


Generate an Esri classifier definition (.ecd) file using the Maximum Likelihood Classifier (MLC) classification definition.


  • 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 Samples Manager from the Classification Tools.

  • 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.


TrainMaximumLikelihoodClassifier (in_raster, in_training_features, out_classifier_definition, {in_additional_raster}, {used_attributes})
ParameterExplanationData Type

Select the raster dataset you want to classify.

Raster Layer; Mosaic Layer; Image Service; String

Select the training sample file or layer that delineates your training sites.

These can be either shapefiles or feature classes, which contain your training samples.

Feature Layer

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.


Optionally incorporate ancillary raster datasets, such as a segmented image or DEM.

Raster Layer; Mosaic Layer; Image Service; String

Specify the attributes to be included in the attribute table associated with the output raster.

  • COLORThe RGB color values are derived from the input raster, on a per-segment basis.
  • MEANThe average digital number (DN), derived from the optional pixel image, on a per-segment basis.
  • STDThe standard deviation, derived from the optional pixel image, on a per-segment basis.
  • COUNTThe number of pixels comprising 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, where 1 is a circle.
  • RECTANGULARITYThe degree to which the segment is rectangular, on a per-segment basis. The values range from 0 to 1, where 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 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.


Code sample

TrainMaximumLikelihoodClassifier example 1 (Python window)

The following Python window script demonstrates how to use this tool.

import arcpy
from import *

    "c:/test/moncton_seg.tif", "c:/test/train.gdb/train_features", 
    "c:/output/moncton_sig.ecd", "c:/test/moncton.tif", 
TrainMaximumLikelihoodClassifier example 2 (stand-alone script)

This example shows how to train a maximum likelihood classifier.

# Import system modules
import arcpy
from 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"

# Execute 
TrainMaximumLikelihoodClassifier(inSegRaster, train_features, out_definition, 
                                 in_additional_raster, attributes)

Licensing information

  • ArcGIS Desktop Basic: Requires Spatial Analyst or Image Analyst
  • ArcGIS Desktop Standard: Requires Spatial Analyst or Image Analyst
  • ArcGIS Desktop Advanced: Requires Spatial Analyst or Image Analyst

Related topics