Polygon in Linie (Datenmanagement)

Lizenzstufe:BasicStandardAdvanced

Zusammenfassung

Erstellt eine Feature-Class, die Linien enthält, die aus Polygongrenzen mit oder ohne Berücksichtigung benachbarter Polygone umgewandelt wurden.

Bild

Abbildung "Polygon in Linie"

Verwendung

Syntax

PolygonToLine_management (in_features, out_feature_class, {neighbor_option})
ParameterErläuterungDatentyp
in_features

Die Eingabe-Features müssen Polygone sein.

Feature Layer
out_feature_class

Die Ausgabe-Line-Feature-Class

Feature Class
neighbor_option
(optional)

Gibt an, ob Informationen zu benachbarten Polygonen identifiziert und gespeichert werden sollen.

  • IDENTIFY_NEIGHBORSInformationen zu benachbarten Polygonen werden identifiziert und in der Ausgabe gespeichert. Wenn verschiedene Segmente eines Polygons ihre Grenze mit anderen Polygonen teilen, wird die Grenze so geteilt, dass jedes eindeutig gemeinsame Segment zu einer Linie wird. Die FIDs der beiden benachbarten Polygone werden in der Ausgabe gespeichert. Dies ist die Standardeinstellung.
  • IGNORE_NEIGHBORSInformationen zu benachbarten Polygonen werden ignoriert. Jede Polygongrenze wird zu einem Linien-Feature; die ursprüngliche Polygon-Feature-ID wird in der Ausgabe gespeichert.
Boolean

Codebeispiel

PolygonToLine - Beispiel 1 (Python-Fenster)

Das folgende Skript im Python-Fenster veranschaulicht, wie die Funktion "PolygonToLine" im unmittelbaren Modus verwendet wird.

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.PolygonToLine_management("Habitat_Analysis.gdb/vegtype", 
                               "C:/output/Output.gdb/vegtype_lines",
                               "IGNORE_NEIGHBORS")
PolygonToLine - Beispiel 2 (eigenständiges Skript)

Das folgende eigenständige Skript ist ein einfaches Beispiel für die Anwendung der Funktion "PolygonToLine" in einer Scripting-Umgebung.

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

# import system modules 
import arcpy
from arcpy import env

# Set environment settings
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, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message

Umgebung

Verwandte Themen

Lizenzierungsinformationen

ArcGIS for Desktop Basic: Nein
ArcGIS for Desktop Standard: Nein
ArcGIS for Desktop Advanced: Ja
5/9/2014