Skip To Content

Generalizing zones with Shrink, and Expand

Available with Spatial Analyst license.

The tools in the Generalization toolset that generalize zones include Shrink and Expand.

Shrink

The Shrink tool shrinks specified zones by replacing them with the value of the cell that is most frequent in its neighborhood. In Shrink, the values of spurious cells along zonal boundaries are changed to the value of their highest frequency neighbor. Any cells that are not internal cells (those that cannot be viewed as a center to eight nearest neighbors of the same value) may be replaced.

Thin islands inside a zone, which can be viewed as sharing boundaries with the zone, may also be replaced. You can control how many cells to shrink with the Shrink tool. When you shrink by one cell, the smallest size region that can be retained is a 3-by-3 block of cells (3 by 2 at an edge, or 2 by 2 in a corner). Thin portions of regions can be replaced.

For example, a region that is 2 cells wide and 10 cells long will be removed, since it will shrink by one cell from two different directions. If you shrink by two cells, the smallest size region that can be retained is a 5-by-5 block of cells.

When you shrink by more than one cell, conceptually, it is like running the tool as many times as the number of cells to shrink with the results of the previous run being the input to the subsequent iteration.

For example, if you shrink by two cells, conceptually, it is like running Shrink by one cell on the input raster and shrinking the identified zones and using the output of the first shrink as the input for the second shrinking.

In the image below, Shrink is applied to the input raster, so zone 5 shrinks by one cell. Zone 5 is no more than two cells wide in any area; therefore, all cells containing 5 are replaced with the value of highest frequency in its neighborhood. NoData invades two locations at the bottom right, since it is the value of highest frequency to the two locations.

Shrink illustration
OutRas = Shrink(InRas1, 1, [5])

In the image below, Shrink is applied to the input raster, so zones 4 and 6 shrink by one cell. In the upper left corner, a value 4 remains, since it is deeper than one cell.

Shrink illustration
OutRas = Shrink(InRas1, 1, [5])

Expand

With the Expand tool, certain zones can expand into other zones. Conceptually, selected values can be viewed as foreground zones, while others remain background zones. The foreground zones can expand into the background zones.

In the image below, the Expand tool is applied to the input raster with zone 5 expanding one cell. Notice that zone 5 expanded into the NoData values in the lower right.

Expand illustration
OutRas = Expand(InRas1, 1, [5])

Related topics


In this topic
  1. Shrink
  2. Expand