Trim Line (Editing)

License Level:BasicStandardAdvanced

Summary

Removes portions of a line that extend a specified distance past a line intersection (dangles). Any line that does not touch another line at both endpoints can be trimmed, but only the portion of the line that extends past the intersection by the specified distance will be removed.

Tool use is intended for quality control tasks such as cleaning up topology errors in features that were digitized without having set proper snapping environments.

Illustration

Trim Line illustration

Usage

Syntax

TrimLine_edit (in_features, {dangle_length}, {delete_shorts})
ParameterExplanationData Type
in_features

The line input features to be trimmed.

Feature Layer
dangle_length
(Optional)

Line segments that are shorter than the specified Dangle Length and do not touch another line at both endpoints (dangles) will be trimmed.

If no Dangle Length is specified, all dangling lines (line segments that do not touch another line at both endpoints), regardless of length, will be trimmed back to the point of intersection.

Linear Unit
delete_shorts
(Optional)

Controls whether line segments which are less than the dangle length and are free-standing will be deleted.

  • DELETE_SHORT Delete short free-standing features. This is the default.
  • KEEP_SHORTDo not delete short free-standing features.
Boolean

Code Sample

Trim Line Example (Python Window)

The following Python Window script demonstrates how to use the Trim Line tool.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.TrimLine_edit("majorrds.shp", "15 Feet", "DELETE_SHORT")
Trim Line Example (Stand-alone script)

Clean up street centerlines that were digitized without having set proper snapping environments.

# Name: ExtendLine.py
# Description:  Clean up street centerlines that were digitized without 
#                      having set proper snapping environments
# Author: ESRI

# import system modules 
import arcpy
from arcpy import env

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

# Make backup copy of streets feature class, since modification with 
#  the Editing tools below is permanent
streets = "majorrds.shp"
streetsBackup = "C:/output/Output.gdb/streetsBackup"
arcpy.CopyFeatures_management(streets, streetsBackup)

# Trim street lines to clean up dangles
arcpy.TrimLine_edit(streets, "10 Feet", "KEEP_SHORT")

# Extend street lines to clean up dangles
arcpy.ExtendLine_edit(streets, "15 Feet", "EXTENSION")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
3/6/2014