Skip To Content

Class Probability

Available with Spatial Analyst license.


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


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

  • 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 Add Data button next to Input raster bands, open the raster, and select the desired bands.
    • If the multiband raster is a layer in the 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.
  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.


ClassProbability (in_raster_bands, in_signature_file, {maximum_output_value}, {a_priori_probabilities}, {in_a_priori_file})
ParameterExplanationData Type

The input raster bands.

They can be integer or floating point type.

Raster Layer

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

A .gsg extension is required.


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

By default, the values range from 0 to 100.


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.

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.


Return Value

NameExplanationData Type

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.


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 import *
env.workspace = "C:/sapyexamples/data"
outClassProbability = ClassProbability("redlands","C:/sapyexamples/data/wedit5.gsg",
ClassProbability example 2 (stand-alone script)

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

# Name:
# 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 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"c:/sapyexamples/output/classprob01")

Licensing information

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

Related topics