Thin (Spatial Analyst)

Available with Spatial Analyst license.

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.

  • If enabled, the filter option uses the same filtering algorithm as the Boundary Clean tool 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

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

Parameters

LabelExplanationData Type
Input 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.

  • Zero — The background is composed of cells of 0 or less, or NoData. All cells whose value is greater than 0 are the foreground.
  • NoData — The background is composed of NoData cells. All cells with valid values belong to the foreground.
String
Filter input first
(Optional)

Specifies whether a filter will be applied as the first phase of thinning.

  • Unchecked—No filter will be applied. This is the default.
  • Checked—The raster will be filtered to smooth the boundaries between foreground and background cells. This option will eliminate minor irregularities from the output raster.
Boolean
Shape for corners
(Optional)

Specifies whether round or sharp turns will be made at turns or junctions.

  • Round — Attempts to smooth corners and junctions. This is best for vectorizing natural features, such as contours or streams.
  • Sharp — Attempts to preserve rectangular corners and junctions. This is best for vectorizing man-made features such as streets.
String
Maximum thickness of input linear features
(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

LabelExplanationData Type
Output raster

The output thinned raster.

The output is always of integer type.

Raster

Thin(in_raster, {background_value}, {filter}, {corners}, {maximum_thickness})
NameExplanationData 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.

  • ZEROThe background is composed of cells of 0 or less, or NoData. All cells whose value is greater than 0 are the foreground.
  • NODATA The background is composed of NoData cells. All cells with valid values belong to the foreground.
String
filter
(Optional)

Specifies whether a filter will be applied as the first phase of thinning.

  • NO_FILTERNo filter will be applied.This is the default.
  • FILTER The raster will be filtered to smooth the boundaries between foreground and background cells. This option will eliminate minor irregularities from the output raster.
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.

  • ROUND Attempts to smooth corners and junctions. This is best for vectorizing natural features, such as contours or streams.
  • SHARP Attempts to preserve rectangular corners and junctions. This is best for vectorizing man-made features such as streets.
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

NameExplanationData Type
out_raster

The output thinned raster.

The output is always of integer type.

Raster

Code sample

Thin example 1 (Python window)

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")
Thin example 2 (stand-alone script)

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

# Execute Thin
thinOut = Thin(inRaster, "NODATA", "FILTER", "SHARP", tolerance)

# Save the output 
thinOut.save("c:/sapyexamples/output/thinoutput")

Licensing information

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

Related topics