Maximum Likelihood Classification (Spatial Analyst)
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.
-
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. If you want to process a subset of the bands in the source dataset, you can use the Make Raster Layer tool to create an input layer containing the desired bands.
-
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.
-
The extension for an input a priori probability file is .txt.
Syntax
Parameter | Explanation | Data 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.
| 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
Name | Explanation | Data Type |
out_classified_raster |
The output classified raster. | Raster |
Code Sample
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")
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 # Author: ESRI # 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")