Equal To Frequency (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Evaluates on a cell-by-cell basis the number of times the values in a set of rasters are equal to another raster.

Illustration

Example Equal To Frequency tool input and output values
OutRas = EqualToFrequency(ValRas, [InRas1, InRas2, InRas3])

Usage

  • An arbitrary number of rasters can be specified in the input rasters list.

  • If a cell location contains NoData on any of the input rasters, that location will be assigned NoData on the output.

  • The output raster is always of integer type.

  • In ArcPy, if all inputs are multidimensional rasters with the same number of variables, the tool will perform the operation for all slices with the same dimension value, and the output will be a multidimensional raster. The variables in the inputs must have the same dimensions or common dimensions.

    If all of the inputs are multidimensional rasters with one variable but different names, set the matchMultidimensionalVariable geoprocessing environment to False to perform the operation.

    In ArcPy, if one or more of the inputs is a multidimensional raster and the other input is a constant, the tool will perform the operation for all slices for all variables using the constant value, and the output will be a multidimensional raster.

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

Parameters

LabelExplanationData Type
Input value raster

For each cell location in the input value raster, the number of occurrences (frequency) where a raster in the input list has an equal value is counted.

Raster Layer
Input rasters

The list of rasters that will be compared to the value raster.

Raster Layer
Process as multiband
(Optional)

Specifies how the input multiband raster bands will be processed.

  • Unchecked—Each band from a multiband raster input will be processed separately as a single band raster. This is the default.
  • Checked—Each multiband raster input will be processed as a multiband raster. The operation will be performed for each band from one input using the corresponding band number from the other inputs.
Boolean

Return Value

LabelExplanationData Type
Output raster

The output raster.

For each cell in the output raster, the value represents the number of times that the corresponding cells in the list of rasters are the same as the value raster.

Raster

EqualToFrequency(in_value_raster, in_rasters, {process_as_multiband})
NameExplanationData Type
in_value_raster

For each cell location in the input value raster, the number of occurrences (frequency) where a raster in the input list has an equal value is counted.

Raster Layer
in_rasters
[in_raster,...]

The list of rasters that will be compared to the value raster.

Raster Layer
process_as_multiband
(Optional)

Specifies how the input multiband raster bands will be processed.

  • SINGLE_BANDEach band from a multiband raster input will be processed separately as a single band raster. This is the default.
  • MULTI_BANDEach multiband raster input will be processed as a multiband raster. The operation will be performed for each band from one input using the corresponding band number from the other inputs.
Boolean

Return Value

NameExplanationData Type
out_raster

The output raster.

For each cell in the output raster, the value represents the number of times that the corresponding cells in the list of rasters are the same as the value raster.

Raster

Code sample

EqualToFrequency example 1 (Python window)

This example evaluates the number of times a set of input rasters is equal to another raster and outputs the result as a TIFF raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outETF = EqualToFrequency("cost", ["degs", "negs", "fourgrd"])
outETF.save("C:/sapyexamples/output/outetf.tif")
EqualToFrequency example 2 (stand-alone script)

This example evaluates the number of times a set of input rasters is equal to another raster and outputs the result as a Grid raster.

# Name: EqualToFrequency_Ex_02.py
# Description: Evaluates the number of times a set of rasters is
#              equal to another raster on a cell-by-cell basis
# 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
inValueRaster = "cost"
inRaster01 = "degs"
inRaster02 = "negs"
inRaster03 = "fourgrd"

# Execute EqualToFrequency
outETF = EqualToFrequency(inValueRaster, [inRaster01, inRaster02, inRaster03])

# Save the output 
outETF.save("C:/sapyexamples/output/outETF")

Licensing information

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

Related topics