Boundary Clean (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Smooths the boundary between zones in a raster.

Learn more about how Boundary Clean works

Illustration

Boundary Clean tool illustration
OutRas = BoundaryClean(InRas1)

Usage

  • The Boundary Clean tool generalizes, or simplifies, rasters by smoothing the boundaries between zones. The tool provides options for controlling how the cells of the zones in the input influence the smoothing and the amount of smoothing that will be applied.

  • The tool applies the mathematical morphology techniques of expansion (dilation) and shrinking (erosion) when smoothing the boundaries (Serra, 1982). Each input cell is evaluated using its immediate orthogonal and diagonal neighbors.

  • The smoothing process first sorts the neighbor cells by a particular priority. The priority determines which zone from the neighboring cells can replace the value of the processing cell in the output.

  • The priority can be based on either the value of the zones or the size of the zones. The Sort type parameter (sort_type in Python) determines the sorting type to use.

    The default method, Do not sort (NO_SORT in Python), assesses the priority based on the value of the zones. Cells from zones with larger values will have a higher priority to expand into zones with smaller values. The size of the zones is not considered.

    The size, or total area, of the zones can be used to sort the priority. The size is determined by the count of cells that compose each zone. With the Descending setting (DESCEND in Python), the zones are sorted by size in descending order. The zones with larger total areas will have the priority to expand into zones with smaller areas. With the Ascending setting (ASCEND in Python), the opposite is true: zones with smaller total areas will have the priority to expand into zones with larger total areas.

  • The amount of smoothing is controlled by the Run expansion and shrinking twice parameter (number_of_runs in Python), which determines the number of times the expand and shrinking process will be performed.

    With the unchecked setting (ONE_WAY in Python), the expand and shrink process is performed once. With the checked setting (TWO_WAY in Python), the expand and shrink process is performed twice, resulting in an additional degree of smoothing of the zone boundaries.

    For additional details about the algorithm, see the Boundary Clean section of Smoothing zone edges with Boundary Clean and Majority Filter.

  • If the values of all eight neighbor cells are the same as the processing cell, the output cell will retain the value of the input cell.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

  • Reference:

    Serra, J. Image Analysis and Mathematical Morphology, Academic Press, London 1982.

Parameters

LabelExplanationData Type
Input raster

The input raster for which the boundary between zones will be smoothed.

It must be of integer type.

Raster Layer
Sort type
(Optional)

Specifies the type of sorting to use in the smoothing process. The sorting determines the priority by which cells can expand into their neighbors.

The sorting can be based on zone value or zone size.

  • Do not sortThe priority is determined by zone value. The size of the zones is not considered. Zones with larger values will have a higher priority to expand into zones with smaller values in the smoothed output. This is the default.
  • DescendingZones are sorted in descending order by size. Zones with larger total areas have a higher priority to expand into zones with smaller total areas. This option tends to eliminate or reduce the prevalence of cells from smaller zones in the smoothed output.
  • AscendingZones are sorted in ascending order by size. Zones with smaller total areas have a higher priority to expand into zones with larger total areas. This option tends to preserve or increase the prevalence of cells from smaller zones in the smoothed output.
String
Run expansion and shrinking twice
(Optional)

Specifies the number of times the smoothing process will occur, twice or once.

  • Checked—The expansion and shrinking operation is performed twice. The first time, the operation is performed according to the specified sort type. The second time, an additional expansion and shrinking operation is performed with the priority reversed. This is the default.
  • Unchecked—The expansion and shrinking operation is performed once according to the sort type.
Boolean

Return Value

LabelExplanationData Type
Output raster

The output generalized raster.

The boundaries between zones in the input will be smoothed.

The output is always of integer type.

Raster

BoundaryClean(in_raster, {sort_type}, {number_of_runs})
NameExplanationData Type
in_raster

The input raster for which the boundary between zones will be smoothed.

It must be of integer type.

Raster Layer
sort_type
(Optional)

Specifies the type of sorting to use in the smoothing process. The sorting determines the priority by which cells can expand into their neighbors.

The sorting can be based on zone value or zone size.

  • NO_SORTThe priority is determined by zone value. The size of the zones is not considered. Zones with larger values will have a higher priority to expand into zones with smaller values in the smoothed output. This is the default.
  • DESCENDZones are sorted in descending order by size. Zones with larger total areas have a higher priority to expand into zones with smaller total areas. This option tends to eliminate or reduce the prevalence of cells from smaller zones in the smoothed output.
  • ASCENDZones are sorted in ascending order by size. Zones with smaller total areas have a higher priority to expand into zones with larger total areas. This option tends to preserve or increase the prevalence of cells from smaller zones in the smoothed output.
String
number_of_runs
(Optional)

Specifies the number of times the smoothing process will occur, twice or once.

  • TWO_WAYThe expansion and shrinking operation is performed twice. The first time, the operation is performed according to the specified sort type. The second time, an additional expansion and shrinking operation is performed with the priority reversed. This is the default.
  • ONE_WAYThe expansion and shrinking operation is performed once according to the sort type.
Boolean

Return Value

NameExplanationData Type
out_raster

The output generalized raster.

The boundaries between zones in the input will be smoothed.

The output is always of integer type.

Raster

Code sample

BoundaryClean example 1 (Python window)

This example smooths the boundary between zones in descending order with a two-way run.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
OutBndCln = BoundaryClean("land", "DESCEND", "TWO_WAY")
OutBndCln.save("c:/sapyexamples/output/bndcln_des2")
BoundaryClean example 2 (stand-alone script)

This example smooths the boundary between zones in descending order with a two-way run.

# Name: BoundaryClean_Ex_02.py
# Description: Smoothes the boundary between zones 
#              by expanding and shrinking it.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "land"

# Execute BoundaryClean
OutBndCln = BoundaryClean(inRaster, "ASCEND", "TWO_WAY")

# Save the output 
OutBndCln.save("c:/sapyexamples/output/bndcln_asc2")

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics