Summary
Creates a feature class containing lines that are converted from polygon boundaries with or without considering neighboring polygons.
Illustration
Usage
If the checkbox Identify and store polygon neighboring information is checked (the neighbor_option is set to IDENTIFY_NEIGHBORS in scripting), the polygon neighboring relationship will be analyzed. As illustrated above, the boundaries are converted to lines taking into account of crossing or shared segments; two new fields, LEFT_FID and RIGHT_FID, will be added to the output feature class and set to the feature IDs of the input polygons to the left and right of each output line. The attributes of the input features will not be maintained in the output feature class. The following scenarios help you understand 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 LEFT_FID and the polygon feature ID as the RIGHT_FID.
- If a polygon contains another polygon, one output line in the clockwise direction will be generated representing the shared boundary, with its LEFT_FID set to the outer polygon feature ID and the RIGHT_FID set to the inner polygon feature ID.
- If two polygons share a portion of their boundaries, one output line will be generated representing the shared segment. The line direction will be arbitrary; the LEFT_FID and the RIGHT_FID will be set to the left or right polygon feature IDs accordingly.
- If 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, therefore, its LEFT_FID is the feature ID of the polygon it crosses and its RIGHT_FID will be its own polygon feature ID; the second line will be in the opposite direction, splitting the other polygon, therefore, its LEFT_FID and RIGHT_FID will be the same as the other polygon feature ID.
- Multiparts in input polygons are not maintained; the output lines are all singlepart.
If the checkbox Identify and store polygon neighboring information is unchecked (the neighbor_option is set to IGNORE_NEIGHBORS in scripting), the polygon neighboring relationship will be ignored. Each input polygon boundary will be written out as an enclosed line feature. A multipart polygon will become a multipart line in the output. The attributes of the input features will be maintained in the output feature class. A new field, ORIG_FID, will be added to the output and set to the input feature IDs of each line.
For parametric (true) curve input features, the output lines will remain true curves even if they are split. This does not apply to shapefile data.
This tool will use a tiling process to handle very large datasets for better performance and scalability. For more details, see Geoprocessing with large datasets.
Syntax
PolygonToLine_management (in_features, out_feature_class, {neighbor_option})
Parameter | Explanation | Data Type |
in_features | The input features that must be polygon. | Feature Layer |
out_feature_class | The output line feature class. | Feature Class |
neighbor_option (Optional) | Specifies whether or not to identify and store polygon neighboring information.
| 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.PolygonToLine_management("Habitat_Analysis.gdb/vegtype",
"C:/output/Output.gdb/vegtype_lines",
"IGNORE_NEIGHBORS")
PolygonToLine Example 2 (stand-alone script)
The following stand-alone script is a simple example of how to apply the PolygonToLine function in a scripting environment.
# Name: PolygonToLine_Example2.py
# Description: Use 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"
# Use error trapping in case a problem occurs when running the tool
try:
# Run PolygonToLine to convert polygons to lines using default neighbor_option
arcpy.PolygonToLine_management(inFeatureClass, outFeatureClass)
# Select lines that have LEFT_FID values greater than -1
arcpy.MakeFeatureLayer_management(outFeatureClass, "selection_lyr",
"\"LEFT_FID\" > -1")
result = arcpy.GetCount_management("selection_lyr")
if (result.getOutput(0) == "0"):
print("No overlapping or shared boundary lines were found.")
else:
print(result.getOutput(0) + " overlapping or shared boundary lines were found.")
except Exception as err:
print(err.args[0])
Environments
Licensing information
- ArcGIS for Desktop Basic: No
- ArcGIS for Desktop Standard: No
- ArcGIS for Desktop Advanced: Yes