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

Trim Line illustration

Usage

    Caution:

    This tool modifies the input data. See Tools that modify or update the input data for more information and strategies to avoid undesired data changes.

  • 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 geodatabase feature class.

Parameters

LabelExplanationData Type
Input 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 a dangle length is not 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 Short Features
(Optional)

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

  • Checked—Delete short free-standing features. This is the default.
  • Unchecked—Do not delete short free-standing features.
Boolean

Derived Output

LabelExplanationData Type
Updated Input Features

The updated input features.

Feature Class

arcpy.edit.TrimLine(in_features, {dangle_length}, {delete_shorts})
NameExplanationData 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 a dangle length is not 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)

Specifies 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

Derived Output

NameExplanationData Type
out_feature_class

The updated input features.

Feature Class

Code sample

TrimLine example 1 (Python window)

The following Python window script demonstrates how to use the TrimLine function.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.TrimLine_edit("majorrds.shp", "15 Feet", "DELETE_SHORT")
TrimLine example 2 (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

# import system modules 
import arcpy

# Set environment settings
arcpy.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")

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics