Generalizing zones with Nibble, Shrink, and Expand

Spatial Analyst tools that generalize zones include Nibble, Shrink, and Expand.

Nibble

The Nibble tool allows selected areas of a raster to be assigned the value of their nearest neighbor. This is useful for editing areas of a raster where the data is known to be erroneous.

First, the algorithm determines all areas from the mask raster with the value NoData. The corresponding areas on the input raster will be nibbled. Second, an internal Euclidean allocation is performed to allocate values to the masked cells based on Euclidean distance.

The value of the cells from the input raster that correspond to the cells of NoData from the mask raster are nibbled and replaced by the value of the nearest neighbor according to Euclidean distance.

In the following image, Nibble was applied to the input and mask rasters. Nibble will only be applied to the NoData values in the mask raster. Notice all non-NoData cells on the mask raster receive the value from the input raster. These cell values and their locations will be used to assign values to the NoData locations identified on the mask raster. The NoData locations will receive the value of the cell in the input raster that is identified as the closest non-NoData cell on the mask raster.

Nibble illustration
OutRas = Nibble(InRas1, Mask_Ras)

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


6/29/2011