Available with Spatial Analyst license.
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 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})
Parameter | Explanation | Data 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
| String |
a_priori_probabilities (Optional) | Specifies how a priori probabilities will be determined.
| 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
Name | Explanation | Data 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
Licensing Information
- ArcGIS for Desktop Basic: Requires Spatial Analyst
- ArcGIS for Desktop Standard: Requires Spatial Analyst
- ArcGIS for Desktop Advanced: Requires Spatial Analyst