Available with Spatial Analyst license.
Illustration
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.
References:
- Serra, J. Image Analysis and Mathematical Morphology, Academic Press, London 1982.
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})
Parameter | Explanation | Data 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.
| String |
number_of_runs (Optional) | Specifies the number of times the smoothing process will occur, twice or once.
| Boolean |
Return Value
Name | Explanation | Data 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
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")
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")
Environments
Licensing information
- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst