Polygon To Line (Data Management)

Summary

Creates a line feature class converted from polygon boundaries. You can set the tool parameters so shared segments and their neighboring polygon feature IDs will be analyzed. Alternatively, you can set the tool parameters so an enclosed line feature will be created for each input polygon.

Illustration

Polygon To Line tool illustration

Usage

  • If the Identify and store polygon neighboring information parameter is checked, the polygon neighboring relationship will be analyzed. The boundaries are converted to lines, taking into account crossing or shared segments. The following fields will be added the output:

    • LEFT_FID—The feature ID of the input polygon to the left of the output line.
    • RIGHT_FID—The feature ID of the input polygon to the right of the output line.
    The attributes of the input features will not be maintained in the output.

    The following scenarios describe the process and output in more detail:

    • In a polygon geometry, the outer boundary is always stored in a clockwise direction. If the polygon has a hole, the hole (or inner) boundary is always stored in a counterclockwise direction. Therefore, for a polygon with no neighbors to the left side (outside) of its outer boundary and the left side (inside) of the hole boundary, the resulting lines will have a value of -1 for the LEFT_FID field value and the polygon feature ID as the RIGHT_FID field value.
    • When a polygon contains another polygon, one output line in the clockwise direction will be generated representing the shared boundary, and its LEFT_FID field value will be the outer polygon feature ID and the RIGHT_FID field value will be the inner polygon feature ID.
    • When two polygons share a portion of their boundaries, one output line will be generated representing the shared segment. The line direction will be arbitrary, and the LEFT_FID and RIGHT_FID field values will be the left or right polygon feature ID accordingly.
    • When a polygon overlaps another polygon, two output lines will be generated representing each crossing boundary twice. The first line will represent the outer boundary of one of the overlapping polygons, and its LEFT_FID field value will be the feature ID of the polygon it crosses, and its RIGHT_FID field value will be its own polygon feature ID. The second line will be in the opposite direction, splitting the other polygon, and its LEFT_FID and RIGHT_FID field values will be the same as the other polygon feature ID.
    • Input multipart features are not maintained; the output lines will all be single part.

    For any input feature that is a parametric (true) curve, the output line will remain true curves, even if they are split

    This parameter uses a tiling process to handle very large datasets for better performance and scalability.

  • When the Identify and store polygon neighboring information parameter is unchecked, each input polygon will be converted to an enclosed line feature. Any multipart polygons will be converted to a multipart line.

    A ORIG_FID field will be added to the output with the feature ID of each input line. The attributes of the input features will be maintained in the output.

Parameters

LabelExplanationData Type
Input Features

The input polygon features.

Feature Layer
Output Feature Class

The output line feature class.

Feature Class
Identify and store polygon neighboring information
(Optional)

Specifies whether polygon neighboring relationships will be identified and stored in the output.

  • Checked—Polygon neighboring relationships will be identified and stored in the output. If different segments of a polygon share a boundary with other polygons, the boundary will be split so that each uniquely shared segment will become a line with its two neighboring polygon feature IDs stored in the output. This is the default.
  • Unchecked—Polygon neighboring relationships will be ignored; every polygon boundary will become a line feature with its original polygon feature ID stored in the output.

Boolean

arcpy.management.PolygonToLine(in_features, out_feature_class, {neighbor_option})
NameExplanationData Type
in_features

The input polygon features.

Feature Layer
out_feature_class

The output line feature class.

Feature Class
neighbor_option
(Optional)

Specifies whether polygon neighboring relationships will be identified and stored in the output.

  • IDENTIFY_NEIGHBORSPolygon neighboring relationships will be identified and stored in the output. If different segments of a polygon share a boundary with other polygons, the boundary will be split so that each uniquely shared segment will become a line with its two neighboring polygon feature IDs stored in the output. This is the default.
  • IGNORE_NEIGHBORSPolygon neighboring relationships will be ignored; every polygon boundary will become a line feature with its original polygon feature ID stored in the output.
Boolean

Code sample

PolygonToLine example 1 (Python window)

The following Python window script demonstrates how to use the PolygonToLine function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.PolygonToLine("Habitat_Analysis.gdb/vegtype", 
                               "C:/output/Output.gdb/vegtype_lines",
                               "IGNORE_NEIGHBORS")
PolygonToLine example 2 (stand-alone script)

The following stand-alone script is an example of how to use the PolygonToLine function.

# Name: PolygonToLine_Example2.py
# Description: Use the PolygonToLine function to convert polygons to lines,
#              and report how many shared or overlapping boundary lines
#              were found.

# Import system modules 
import arcpy

# Set environment settings
arcpy.env.workspace = "C:/data/landcovers.gdb"
 
# Create variables for the input and output feature classes
inFeatureClass = "bldgs"
outFeatureClass = "bldgs_lines"
 
# Run PolygonToLine to convert polygons to lines using default neighbor_option
arcpy.management.PolygonToLine(inFeatureClass, outFeatureClass)

# Select lines that have LEFT_FID values greater than -1
arcpy.management.MakeFeatureLayer(outFeatureClass, "selection_lyr", 
                                  "\"LEFT_FID\" > -1")
result = arcpy.management.GetCount("selection_lyr")

if result[0] == "0":
    print("No overlapping or shared boundary lines were found.")
else:
    print(f"{result[0]} overlapping or shared boundary lines were found.")

Licensing information

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

Related topics