Focal Statistics function

Available with Spatial Analyst license.

Available with Image Analyst license.

Overview

Calculates statistics on the cells within a neighborhood around each cell of an input raster. Several shapes of neighborhood are available.

Notes

If the input raster is of floating-point type, only the Mean, Maximum, Median, Minimum, Percentile, Range, Standard Deviation, and Sum statistics are available.

When a circular, annulus-shaped, or wedge-shaped neighborhood is specified, some of the outer diagonal cells may not be considered in the calculations since the center of the cell must be encompassed within the neighborhood.

Input NoData cells may receive a value in the output if the Ignore Nodata in Calculations option is checked, provided at least one cell within the neighborhood has a valid value.

For more information on this function, see the Focal Statistics tool topic and the How Focal Statistics works topic in the Spatial Analyst tool help.

Parameters

Parameter nameDescription

Raster

(Required)

The input raster.

Neighborhood

The shape of the area around each cell used to calculate the statistic.

Each neighborhood has additional parameters with which to define the shape.

  • Rectangle, Width, Height

    A rectangular neighborhood defined by width and height. The default is a square with a width and height of three cells.

  • Circle, Radius

    A circular neighborhood with the given radius. The default radius is three cells.

  • Annulus, Inner radius, Outer radius

    A torus (donut-shaped) neighborhood defined by an inner radius and an outer radius. The default annulus has an inner radius of one cell and an outer radius of three cells.

  • Wedge, Radius, Start angle, End angle

    A wedge-shaped neighborhood defined by a radius, the start angle, and the end angle. The wedge extends counterclockwise from the starting angle to the ending angle. Angles are specified in degrees, with 0 or 360 representing east. Negative angles can be used. The default wedge is from 0 to 90 degrees, with a radius of three cells.

  • Irregular, Width, Height, Neighborhood values

    The irregular neighborhood allows you to specify an irregularly shaped neighborhood, or kernel, around the processing cell. Use the neighborhood values table to define the shape of the neighborhood kernel. A value of 1 indicates that its corresponding cell (and value) is a member of the neighborhood. A value of 0 indicates that the cell is not part of the neighborhood.

  • Weight, Width, Height, Neighborhood values

    The weight neighborhood is similar to the irregular neighborhood type, in that it allows you to define an irregular neighborhood around the processing cell, but it additionally allows you to apply weights to the input values. The values in the weight kernel specify which cell positions should be included within the neighborhood and the weights by which they will be multiplied. Use a value of 0 to exclude a cell from processing. Decimal values are valid to use as a weight.

Note:

For the Weight neighborhood type, only the Mean, Standard Deviation, or Sum statistics are supported.

Statistics Type

Specifies the statistic type to be calculated.

  • Mean—Calculates the mean (average value) of the cells in the neighborhood.
  • Majority—Determines the majority (value that occurs most often) of the cells in the neighborhood.
  • Maximum—Determines the maximum (largest value) of the cells in the neighborhood.
  • Median—Calculates the median of the cells in the neighborhood. The median is equivalent to the 50th percentile.
  • Minimum—Determines the minimum (smallest value) of the cells in the neighborhood.
  • Minority—Determines the minority (value that occurs least often) of the cells in the neighborhood.
  • Percentile—Calculates a percentile of the cells in the neighborhood. When this statistics type is selected, a new Percentile Value parameter will become available, with which you can determine which percentile to calculate.
  • Range—Determines the range (difference between largest and smallest value) of the cells in the neighborhood.
  • Standard Deviation—Calculates the standard deviation of the cells in the neighborhood.
  • Sum—Calculates the sum (total of all values) of the cells in the neighborhood.
  • Variety—Determines the variety (the number of unique values) of the cells in the neighborhood.

The default statistic type is Mean.

If the input raster is floating point, only the Mean, Maximum, Median, Minimum, Percentile, Range, Standard Deviation, and Sum statistic types are available.

For Mean, Median, Percentile, and Standard Deviation, the output is always floating point.

For Majority and Minority, if there is a tie between values with the highest (majority) or lowest (minority) frequency in the neighborhood, the processing cell location will receive the lowest of the tied values. If the value of the processing cell itself is one of the ties, that value will be returned instead.

Ignore NoData in Calculations

Specifies whether NoData values are ignored by the statistic calculation.

  • Checked—If a NoData value exists within a neighborhood, the NoData value will be ignored. Only cells within the neighborhood that have data values will be used in determining the output value. This is the default.
  • Unchecked—If any cell in a neighborhood has a value of NoData, the output for the processing cell will be NoData.

Percentile Value

Specifies which percentile to calculate when Percentile is selected as the statistics type. The default is 90, for the 90th percentile.

The values can range from 0 through 100. The 0th percentile is essentially equivalent to the Minimum statistic, and the 100th percentile is equivalent to Maximum, with the exception that the result will be floating point. A value of 50 will essentially produce the same result as the Median statistic.

Kernel files

For the Irregular and Weight neighborhoods, you can save a custom kernel as a text file for later use.

After specifying the width and height, and entering the neighborhood values, use the Save As button to export it to an ASCII text file through the Save Neighborhood Kernel File dialog box. Use the Browse button to open the Input Neighborhood Kernel File dialog box to browse to and specify an existing kernel file to load.

The format of the file is the same as that of the kernel files used in the Focal Statistics geoprocessing tool. The first line records the width and height of the kernel neighborhood in numbers of cells. The subsequent lines indicate how the input value that corresponds to that location in the kernel will be processed.

A value of 0 in the kernel file for either the irregular or the weight neighborhood type indicates the corresponding location will not be included in the calculation. For the irregular neighborhood, a value of 1 in the kernel file indicates that the corresponding input cell will be included in the operation. For the weight neighborhood, the value at each position indicates what the corresponding input cell value is to be multiplied by. Positive, negative, and decimal values are all valid options to use as a weight.