How Focal Statistics works

The Focal Statistics tool performs a neighborhood operation that computes an output raster where the value for each output cell is a function of the values of all the input cells that are in a specified neighborhood around that location. The function performed on the input is a statistic, such as the maximum, average, or sum of all values encountered in that neighborhood.

Conceptually, on execution, the algorithm visits each cell in the raster and calculates the specified statistic with the identified neighborhood. The cell for which the statistic is being calculated is referred to as the processing cell. The value of the processing cell, as well as all the cell values in the identified neighborhood, is included in the neighborhood statistics calculation.

The neighborhoods can overlap, so that cells in one neighborhood may also be included in the neighborhood of another processing cell.


To illustrate the neighborhood processing for Focal Statistics calculating a Sum statistic, consider the processing cell with a value of 5 in the following diagram. A rectangular 3 x 3 cell neighborhood shape is specified. The sum of the values of the neighboring cells (3 + 2 + 3 + 4 + 2 + 1 + 4 = 19) plus the value of the processing cell (5) equals 24 (19 + 5 = 24). So a value of 24 is given to the cell in the output raster in the same location as the processing cell in the input raster.

Example focal neighborhood and processing cell

The above diagram demonstrates how the calculations are performed on a single cell in the input raster. In the following diagram, the results for all the input cells are shown. The cells highlighted in yellow identify the same processing cell and neighborhood as in the example above.

Example input and focal sum output

The shape of a neighborhood can be an annulus (a donut), circle, rectangle, or wedge. The possible statistics that can be calculated within a neighborhood are mean, majority, maximum, median, minimum, minority, range, standard deviation, sum, and variety.

The Focal Statistics tool gives control over the neighborhood type and statistic to be calculated.

Neighborhood types

The shape of a neighborhood can be an annulus (a donut), circle, rectangle, or wedge. By using a kernel file, you can also define a custom neighborhood shape, as well as assign different weights to specific cells in the neighborhood before the statistic is calculated.

Following is a discussion of the different neighborhood shapes and how they are defined:

Statistics type

The available Focal Statistics statistics are majority, maximum, mean, median, minimum, minority, range, standard deviation, and sum. The default statistics type is mean.

Processing cells of NoData

The Ignore NoData in calculations option controls how NoData cells withing the neighbourhood window are handled. When this option is checked (the DATA option), any cells in the neighbourhood that are NoData will be ignored in the calculation of the output cell value. When unchecked (the NODATA option), if any cell in the neighbourhood is NoData, the output cell will be NoData.

If the processing cell itself is NoData, with the Ignore NoData option selected, the output value for the cell will be calculated based on the other cells in the neighbourhood that have a valid value. Of course, if all of the cells in the neighbourhood are NoData, the output will be NoData, regardless of the setting for this parameter.

Related Topics