Summary
Performs a maximum likelihood classification for a set of raster bands and creates the sorted output raster data.
Usage
· Any signature file created by creating a feature, editing a feature, or through the Iso Clustering tool is a valid entry for the input signature file. They all have a. gsg extension.
· By default, all cells in the output raster are categorized, and each class with equal probability weights is appended to the corresponding feature.
· The input priori probability file must be an ASCII file that contains two columns. The value of in represents the class ID. The value in the right column represents the prior probability of the corresponding class. The valid value of a class prior probability must be greater than or equal to zero. If you specify 0 as the probability, the class cannot be displayed in the output raster. Specifies that the sum of the prior 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 class that is ignored in the file receives the average prior probability of the remainder of the value 1. In the example above, all classes from 1 to 8 are represented in the signature file. The prior probabilities of Class 3 and Class 6 are missing in the input priori probability file. Since the sum of all the specified probabilities in the above file equals 0.8, the remainder of the probability (0.2) is divided by the number of unspecified classes (2). Therefore, Class 3 and Class 6 will be assigned a probability of 0.1, respectively.
· The specified reject fraction that is located between any two valid values is assigned to the next higher-level valid value. For example, 0.02 will become 0.025.
· There is a direct relationship between the number of cells in the output raster obtained by the culling fraction and the number of cells represented by the sum of the confidence of the corresponding reject fraction values that are less than the input.
· If you enter a layer created from a multiband raster (more than three bands), the operation takes into account all the bands associated with the source dataset, not just the three bands loaded (symbolized) by the layer.
· You can specify a subset of bands for a multiband raster as input to the tool in several ways.
· If you want to use the tool dialog box, navigate to the multi-band raster by the button next to the input raster bands, open the grid, and select the desired band.
· If the multiband raster is a layer in the table of contents, you can use the Create Raster Layer tool to create a new multiband layer that contains only the desired bands.
· You can also use band compositing to create a new dataset that contains only the desired bands and use the resulting dataset as input to the tool.
• In Python, you can specify the desired bands directly in the tool parameters as a list.
· If the class name in the signature file differs from the class ID, an additional field is added to the output Raster attribute table named CLASSNAME. For each class in the output table, CLASSNAME contains the class name associated with the class. For example, if the class name of each class in the signature file is a descriptive string name (such as coniferous, water, and urban), the names are passed to the CLASSNAME field.
· The extension of the input priori probability file is. txt.
Grammar
Mlclassify (In_raster_bands, In_signature_file, {reject_fraction}, {a_priori_probabilities}, {In_a_priori_file}, { Out_confidence_raster})
Code instance
maximimumlikelihoodclassification Example 1 (Python window)
This example creates a categorical output raster containing five classes from the input signature file and the 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 a categorical output raster containing five classes from the input signature file and the 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")
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
ArcGIS Tutorial: Maximum likelihood classification