Class Probability (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Creates a multiband raster of probability bands, with one band being created for each class represented in the input signature file.

Learn more about how Class Probability works

Usage

  • When a multiband raster is specified as one of the Input raster bands (in_raster_bands in Python), all the bands will be used.

    To process a selection of bands from a multiband raster, you can first create a new raster dataset composed of those particular bands with the Composite Bands tool, and use the result in the list of the Input raster bands (in_raster_bands in Python).

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

  • This tool employs Bayesian statistics to estimate class probabilities. Bayesian statistics involves starting with prior information about the data, then updating that information after the data is collected. The prior information about the data values is quantified with a priori probabilities, which are then adjusted by the likelihood function to receive posterior probabilities (the updated information). The likelihood function is defined by the data values for each class/cluster.

  • 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, no associated probability band will be created for the class in the output multiband raster. The sum of the specified a priori probabilities must be less than or equal to one. An example showing the format of the file 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.

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

  • The value entered for maximum output value sets the upper range of the values in the output probability bands. The default value of 100 creates a multiband raster with each band containing integer values ranging from 0 to 100. Any integer value greater than zero is valid for maximum output value. Only the value of one for the maximum output value argument will result in bands having floating-point values.

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

Parameters

LabelExplanationData Type
Input raster bands

The input raster bands.

They can be integer or floating point type.

Raster Layer
Input signature file

Input signature file whose class signatures are used to generate the a priori probability bands.

A .gsg extension is required.

File
Maximum output value
(Optional)

Factor for scaling the range of values in the output probability bands.

By default, the values range from 0 to 100.

Long
A priori probability weighting
(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
Input a priori probability 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

Return Value

LabelExplanationData Type
Output multiband raster

The output multiband raster dataset.

It will be of integer type.

If the output is an Esri Grid, the filename cannot have more than 9 characters.

Raster

ClassProbability(in_raster_bands, in_signature_file, {maximum_output_value}, {a_priori_probabilities}, {in_a_priori_file})
NameExplanationData Type
in_raster_bands
[in_raster_band,...]

The input raster bands.

They can be integer or floating point type.

Raster Layer
in_signature_file

Input signature file whose class signatures are used to generate the a priori probability bands.

A .gsg extension is required.

File
maximum_output_value
(Optional)

Factor for scaling the range of values in the output probability bands.

By default, the values range from 0 to 100.

Long
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

Return Value

NameExplanationData Type
out_multiband_raster

The output multiband raster dataset.

It will be of integer type.

If the output is an Esri Grid, the filename cannot have more than 9 characters.

Raster

Code sample

ClassProbability example 1 (Python window)

This example creates a multiband raster of probability bands for each class in a signature file.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outClassProbability = ClassProbability("redlands","C:/sapyexamples/data/wedit5.gsg",
                    100,"EQUAL","")
outClassProbability.save("c:/sapyexamples/output/classprob")
ClassProbability example 2 (stand-alone script)

This example creates a multiband raster of probability bands for each class in a signature file.

# Name: ClassProbability_Ex_02.py
# Description: Creates probability layers for each class in a signature file.
# 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 = "redl123"
inSigFile = "c:/sapyexamples/data/wedit5.gsg"
maxValue = 100
aPrioriWeight = "EQUAL"
aPrioriFile = ""

# Execute ClassProbability
outClassProbability = ClassProbability(inRaster,inSigFile,
                    maxValue, aPrioriWeight, aPrioriFile)

# Save the output 
outClassProbability.save("c:/sapyexamples/output/classprob01")

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics