Boundary Clean (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Smooths the boundary between zones by expanding and shrinking it.

Learn more about how Boundary Clean works

Illustration

Boundary Clean illustration
OutRas = BoundaryClean(InRas1)

Usage

  • All regions of less than three cells in the x- or y-direction will be changed.

  • There are two smoothing processes available to use, which differ in the number of times the expansion-shrinking process is performed. With the default enabled setting of Run expansion and shrinking twice (TWO_WAY in Python), the expansion-shrinking process to smooth the input cell values is performed twice, while when the option is not enabled (ONE_WAY in Python), it is only performed one time.

    In the first pass for both techniques, any processing cell in the expanded raster that has a neighbor of the original value of the processing cell, the original value of the processing cell will be recovered. However, in the shrinking operation of the second pass of the two-way option, any cell in the expanded raster that is not completely surrounded by eight cells of the same value will recover its original value.

  • The expansion is identical for the first and second pass.

  • Input cells of NoData have the lowest priority in the one-way sorting type, or in the first pass of two-way sorting. In the second pass of two-way sorting, cells of NoData have the highest priority.

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

Syntax

BoundaryClean(in_raster, {sort_type}, {number_of_runs})
ParameterExplanationData 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.

This determines the priority by which cells can expand into their neighbors.

  • NO_SORTDoes no sorting by size. Zones with larger values have a higher priority to expand into zones with smaller values.This is the default.
  • DESCENDSorts zones in descending order by size. Zones with larger total areas have a higher priority to expand into zones with smaller total areas.
  • ASCENDSorts zones in ascending order by size. Zones with smaller total areas have a higher priority to expand into zones with larger total areas.
String
number_of_runs
(Optional)

Specifies the number of directions in which the smoothing process will take place.

  • TWO_WAYPerforms expansion and shrinking according to sorting type, and then performs an additional shrinking and expansion with the priority reversed.This is the default.
  • ONE_WAYPerforms expansion and shrinking once, according to the sorting 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 a 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 a 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