# Focal Statistics function

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

## Parameters

Parameter nameDescription

Raster

(Required)

The input raster.

Statistics Type

The statistic type to be calculated.

• Mean—Calculates the mean (average value) of the cells in the neighborhood.
• Majority—Calculates the majority (value that occurs most often) of the cells in the neighborhood.
• Maximum—Calculates the maximum (largest value) of the cells in the neighborhood.
• Median—Calculates the median of the cells in the neighborhood.
• Minimum—Calculates the minimum (smallest value) of the cells in the neighborhood.
• Minority—Calculates 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—Calculates 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—Calculates the variety (the number of unique values) of the cells in the neighborhood.

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.

The default statistic type is Mean.

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
• Wedge, Radius, Start angle, End angle
• Irregular, Width, Height, Neighborhood values
• Weight, Width, Height, Neighborhood values

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

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. Positive, negative, and decimal values are all valid options to use as a weight.

##### Note:

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

Ignore NoData in calculations

Denotes whether NoData values are ignored by the statistic calculation.

• Checked—Specifies that 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—Specifies that if any cell in a neighborhood has a value of NoData, the output for the processing cell will be NoData

Percentile Value

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

## Using 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. Then each row of text represents the value of that location in the kernel. For the Irregular neighborhood type, values of 0 and 1 determine which cells will participate in the statistic calculation. A value of 0 means the corresponding location in the neighborhood will be excluded in the calculation of the statistic, and 1 means that location will be included. The Weight neighborhood not only identifies which cell positions should be included within the neighborhood, but also the weights by which the values at those locations will be multiplied.

The Weight neighborhood is only available for the Mean, Standard Deviation, and Sum statistics types.