ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Maximum Likelihood Classification

Available with Spatial Analyst license.

  • Summary
  • Usage
  • Syntax
  • Code Sample
  • Environments
  • Licensing Information

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

  • Any signature file created by the Create Signature, Edit Signature, or Iso Cluster tools is a valid entry for the input signature file. These will have a .gsg extension.

  • By default, all cells in the output raster will be classified, with each class having equal probability weights attached to their signatures.

  • The input a priori probability file must be an ASCII file consisting of two columns. The values in the left column represent class IDs. The values in the right column represent the a priori probabilities for the respective classes. Valid values for class a priori probabilities must be greater than or equal to zero. If zero is specified as a probability, the class will not appear on the output raster. The sum of the specified a priori probabilities must be less than or equal to one. The format of the file is as follows:

        1  .3
        2  .1
        4  .0
        5  .15
        7  .05
        8  .2

    The classes omitted in the file will receive the average a priori probability of the remaining portion of the value of one. In the above example, all classes from 1 to 8 are represented in the signature file. The a priori probabilities of classes 3 and 6 are missing in the input a priori probability file. Since the sum of all probabilities specified in the above file is equal to 0.8, the remaining portion of the probability (0.2) is divided by the number of classes not specified (2). Therefore, classes 3 and 6 will each be assigned a probability of 0.1.

  • A specified reject fraction, which lies between any two valid values, will be assigned to the next upper valid value. For example, 0.02 will become 0.025.

  • There is a direct relationship between the number of unclassified cells on the output raster resulting from the reject fraction and the number of cells represented by the sum of levels of confidence smaller than the respective value entered for the reject fraction.

  • If the input is a layer created from a multiband raster with more than three bands, the operation will consider all the bands associated with the source dataset, not just the three bands that were loaded (symbolized) by the layer.

  • There are several ways you can specify a subset of bands from a multiband raster to use as input into the tool.

    • If using the tool dialog box, browse to the multiband raster using the browse Browse button next to Input raster bands, open the raster, and select the desired bands.
    • If the multiband raster is a layer in the Table of Contents, you can use the Make Raster Layer tool to create a new multiband layer containing only the desired bands.
    • You can also create a new dataset that contains only the desired bands with Composite Bands and use the resulting dataset as input to the tool.
    • In Python, the desired bands can be directly specified in the tool parameter as a list.
  • If the Class Name in the signature file is different than the Class ID, then an additional field will be added to the output raster attribute table called CLASSNAME. For each class in the output table, this field will contain the Class Name associated with the class. For example, if the Class Names for the classes in the signature file are descriptive string names (for example, conifers, water, and urban), these names will be carried to the CLASSNAME field.

  • The extension for an input a priori probability file is .txt.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

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.

While the bands can be integer or floating point type, the signature file only allows integer class values.

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)

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

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
  • 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.
  • FILE —The 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.

It will be of integer type.

Raster Dataset

Return Value

NameExplanationData Type
out_classified_raster

The output classified raster.

It will be of integer type.

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

  • Auto Commit
  • Cell Size
  • Compression
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Raster Statistics
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing Information

  • ArcGIS for Desktop Basic: Requires Spatial Analyst
  • ArcGIS for Desktop Standard: Requires Spatial Analyst
  • ArcGIS for Desktop Advanced: Requires Spatial Analyst

Related Topics

  • An overview of the Multivariate toolset
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal