Maximum Likelihood Classification (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

Performs a maximum likelihood classification on a set of raster bands and creates a classified raster as output.

Learn more about how Maximum Likelihood Classification works

Usage

Syntax

MLClassify (in_raster_bands, in_signature_file, {reject_fraction}, {a_priori_probabilities}, {in_a_priori_file}, {out_confidence_raster})
ParameterExplanationData Type
in_raster_bands
[in_raster_band,...]

The input raster bands.

Raster Layer
in_signature_file

The input signature file whose class signatures are used by the maximum likelihood classifier.

A .gsg extension is required.

File
reject_fraction
(Optional)

Portion of cells that will remain unclassified due to the lowest possibility of correct assignments.

The default is 0.0; therefore, every cell will be classified.

The 14 valid entries are 0.0, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.975, 0.99, and 0.995.

String
a_priori_probabilities
(Optional)

Specifies how a priori probabilities will be determined.

  • EQUAL All classes will have the same a priori probability.
  • SAMPLE A priori probabilities will be proportional to the number of cells in each class relative to the total number of cells sampled in all classes in the signature file.
  • FILEThe a priori probabilities will be assigned to each class from an input ASCII a priori probability file.
String
in_a_priori_file
(Optional)

A text file containing a priori probabilities for the input signature classes.

An input for the a priori probability file is only required when the FILE option is used.

The extension for the a priori file can be .txt or .asc.

File
out_confidence_raster
(Optional)

Output confidence raster dataset showing the certainty of the classification in 14 levels of confidence, with the lowest values representing the highest reliability.

Raster Dataset

Return Value

NameExplanationData Type
out_classified_raster

The output classified raster.

Raster

Code Sample

MaximimumLikelihoodClassification example 1 (Python window)

This example creates an output classified raster containing five classes derived from an input signature file and a multiband raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
mlcOut = MLClassify("redlands", "c:/sapyexamples/data/wedit5.gsg", "0.0", 
                    "EQUAL", "", "c:/sapyexamples/output/redmlcconf")
mlcOut.save("c:/sapyexamples/output/redmlc")
MaximimumLikelihoodClassification example 2 (stand-alone script)

This example creates an output classified raster containing five classes derived from an input signature file and a multiband raster.

# Name: MLClassify_Ex_02.py
# Description: Performs a maximum likelihood classification on a set of 
#    raster bands.
# Requirements: Spatial Analyst Extension

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

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "redlands"
sigFile = "c:/sapyexamples/data/wedit5.gsg"
probThreshold = "0.0"
aPrioriWeight = "EQUAL"
aPrioriFile = ""
outConfidence = "c:/sapyexamples/output/redconfmlc"


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

# Execute 
mlcOut = MLClassify(inRaster, sigFile, probThreshold, aPrioriWeight, 
                    aPrioriFile, outConfidence) 

# Save the output 
mlcOut.save("c:/sapyexamples/output/redmlc02")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst
4/10/2014