Smoothing zone edges with Boundary Clean and Majority Filter

Available with Spatial Analyst license.

The Boundary Clean and Majority Filter tools are used to generalize the edges of zones in a raster. The edges are smoothed to varying degrees either by expanding and shrinking boundaries or by growing or shrinking zones based on the values within the neighborhood of individual locations.

Boundary Clean

The Boundary Clean tool is primarily used for cleaning ragged edges between zones. It uses an expand and shrink method that cleans boundaries on a relatively large scale. Initially, zones of higher priority invade their neighboring zones of lower priority by one cell in all eight directions. Then they shrink back to those cells that are not completely surrounded by the cells of the same value. Any cells that are not internal cells (that is, they can't be viewed as a center to eight nearest neighbors of the same value) may be replaced. For the default method where there is no sorting by size (Do not sort), larger values have a higher priority.

Thin islands inside a zone, which can be viewed as sharing boundaries with the zone, may also be replaced. The smallest size region that can be retained is a 3-by-3 block of cells. Therefore, thin regions may be replaced. For example, a region that is 2 cells wide and 10 cells long will be removed, since it cannot be recovered after shrinking.

In the image below, Boundary Clean was applied to the input raster with no sorting of the zones. Zones with larger values have a higher priority to expand into zones with smaller values. Notice that cells with the value 7 expand into the lower value cells.

Boundary Clean illustration 1
OutRas = BoundaryClean(InRas1)

In the image below, Boundary Clean was applied to the input raster, and the zones were sorted by the ascending order of size. Zones with smaller total areas have a higher priority to expand into zones with larger total areas. Notice that the zones with smaller areas expand into the larger area zones.

Boundary Clean illustration 2
OutRas = BoundaryClean(InRas1, ascend)

Majority Filter

The Majority Filter tool replaces cells based on the majority value in their contiguous neighborhoods. The tool has two criteria to satisfy before a replacement can occur. First, the number of neighboring cells with the same value must be large enough to be the majority value, or at least half the cells must have the same value (depending on the parameter specified). That is, three out of four or five out of eight connected cells must have the same value with the majority parameter and two out of four or four out of eight are needed for the half parameter. Second, those cells must be contiguous to the center of the specified filter (for example, three out of four cells must be the same). The second criteria concerning the spatial connectivity of the cells minimizes the corruption of cellular spatial patterns. If these criteria are not met, no replacement occurs, and the cell retains its value.

In the image below, Majority Filter is applied to the input raster using a filter of the closest four cells, which are the four orthogonal neighboring cells, requiring the majority (three out of four cells) to be the same before a cell will change its value. Only those cells surrounded by three or more (orthogonal) cells with the same value are changed.

Majority Filter illustration 1
OutRas = MajorityFilter(InRas1)

In the image below, the Majority Filter is applied using the closest eight cells as a filter and requiring at least half the values (four out of eight cells) to have the same value before changing the cell's value. Notice there is a greater smoothing effect.

Majority Filter illustration 2
OutRas = MajorityFilter(InRas1, eight, half)

Related topics