Thin (Spatial Analyst)
Summary
Thins rasterized linear features by reducing the number of cells representing the width of the features.
Usage
A typical application for the Thin tool is for processing a scanned elevation contour map. Because of the resolution of the scanner and the width of the lines on the original map, the contours are represented in the resulting raster as linear elements from five to ten cells wide. After running Thin, each contour will be represented as a linear feature of a single cell width.
-
The FILTER option uses the same filtering algorithm as Boundary Clean to remove short linear features extending from the major branch. It can also remove features narrower than three cells.
-
Specifying the maximum thickness of input linear features is essential for thinning rasters where the thickness of linear features may exceed or stay below the default maximum thickness value. The best results can be expected when the maximum thickness fits the thickest linear features to be thinned.
The general algorithm used in the Thin tool is detailed in the following:
Zhan, Cixiang, 1993, A Hybrid Line Thinning Approach, Proceedings Auto-Carto 11, Minneapolis , pp. 396-405
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input raster to be thinned. It must be of integer type. | Raster Layer |
background_value (Optional) |
Specifies the cell value that will identify the background cells. The linear features are formed from the foreground cells.
| String |
filter (Optional) |
Specifies whether a filter will be applied as the first phase of thinning.
| Boolean |
corners (Optional) |
Specifies whether round or sharp turns will be made at turns or junctions. It is also used during the vector conversion process to spline curves or create sharp intersections and corners.
| String |
maximum_thickness (Optional) |
The maximum thickness, in map units, of linear features in the input raster. The default thickness is ten times the cell size. | Double |
Return Value
Name | Explanation | Data Type |
out_raster |
The output thinned raster. | Raster |
Code Sample
This example thins a raster where the background values are NoData, and smooths the boundaries while attempting to preserve corners and junctions.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
thinOut = Thin("land","NODATA", "FILTER", "SHARP", 300)
thinOut.save("c:/sapyexamples/output/thinout")
This example thins a raster where the background values are NoData, and smooths the boundaries while attempting to preserve corners and junctions.
# Name: Thin_Ex_02.py
# Description: Thins rasterized linear features by
# reducing the number of cells
# representing the width of the features.
# 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"
tolerance = 300
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute Thin
thinOut = Thin(inRaster, "NODATA", "FILTER", "SHARP", tolerance)
# Save the output
thinOut.save("c:/sapyexamples/output/thinoutput")