Trim Line (Editing)
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
Usage
Any line that does not touch another line at both endpoints can be trimmed. There are two types of lines that meet this condition:
- A line dangle. A dangle is that portion of a line between the point where it touches or intersects another line and its endpoint -- the end of the line that does not touch or end on another line.
- A free-standing or stand-alone feature. This feature does not touch or intersect any other lines. To delete these features, the Delete Short Features option must be used.
-
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.
-
If the Delete Short Features option is used, any free-standing or stand-alone features with a total length less than or equal to the specified Dangle Length will be deleted. If this option is not used, only dangling line segments will be trimmed.
-
If a feature layer or feature class with a selection is used as the input, only the selected features will be trimmed. All features within the layer or feature class will be used to assess if a dangle exists and should be deleted, but only the selected features will be modified.
-
This tool will not change any feature attributes, except the geometry (length) fields in a personal, file, or ArcSDE geodatabase feature class.
This tool modifies the input data. See Tools with no outputs for more information and strategies to avoid undesired data changes.
Syntax
Parameter | Explanation | Data 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.
| Boolean |
Code Sample
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")
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")