Multipart in Singlepart (Datenmanagement)
Zusammenfassung
Erstellt durch Trennung von Multipart-Eingabe-Features eine Feature-Class mit Singlepart-Features.
Bild
![]()  | 
Verwendung
- 
Die Attribute der Eingabe-Features werden in der Ausgabe-Feature-Class beibehalten. Das Feld "ORIG_FID" wird der Ausgabe-Feature-Class hinzugefügt und auf die IDs des Eingabe-Features gesetzt.
 - 
Die einzelnen Teile des Multipart-Eingabe-Features werden in der Ausgabe-Feature-Class zu einzelnen Singlepart-Features. Features, die bereits Singlepart sind, sind davon nicht betroffen.
 - 
Die meisten Ausgabe-Feature-Typen sind mit den Eingabetypen identisch (Eingabepolygone bleiben Polygone; Eingabelinien bleiben Linien). Eine Ausnahme ist allerdings, wenn die Eingabe-Features vom Typ "Multipoint" sind. Die Ausgabe-Feature-Class ist dann vom Typ "Point".
 - 
Mit dem Werkzeug Zusammenführen (Dissolve) lassen sich aus Singlepart-Features mit einem gemeinsamen Feldwert (beispielsweise ORIG_FID) Multipart-Features erstellen.
 
Syntax
| Parameter | Erläuterung | Datentyp | 
in_features  | 
 Die Eingabe-Features können jedes beliebige unterstützte Format aufweisen.  | Feature Layer | 
out_feature_class  | 
 Die Ausgabe-Feature-Class, die Features enthält, die sich je nach Eingabe-Feature-Typ ändern.  | Feature Class | 
Codebeispiel
Mit dem folgenden Skript im Python-Fenster wird veranschaulicht, wie Sie die Funktion "MultipartToSinglepart" im unmittelbaren Modus verwenden.
import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.MultipartToSinglepart_management("landuse.shp",
                                       "c:/output/output.gdb/landuse_singlepart")
Das folgende eigenständige Skript ist ein einfaches Beispiel für die Anwendung der Funktion "MultipartToSinglepart" in einer Skriptumgebung.
# Name: MultipartToSinglepart_Example2.py
# Description: Break all multipart features into singlepart features,
#              and report which features were separated.
# Author: ESRI
# Import system modules
import arcpy
 
# Create variables for the input and output feature classes
inFeatureClass = "c:/data/gdb.gdb/vegetation"
outFeatureClass = "c:/data/gdb.gdb/vegetation_singlepart"
try:
    # Create list of all fields in inFeatureClass
    fieldNameList = [field.name for field in arcpy.ListFields(inFeatureClass)]
    # Add a field to the input this will be used as a unique identifier
    arcpy.AddField_management(inFeatureClass, "tmpUID", "double")
 
    # Determine what the name of the Object ID is 
    OIDFieldName = arcpy.Describe(inFeatureClass).OIDFieldName
   
    # Calculate the tmpUID to the OID
    arcpy.CalculateField_management(inFeatureClass, "tmpUID",
                                    "[" + OIDFieldName + "]")
 
    # Run the tool to create a new fc with only singlepart features
    arcpy.MultipartToSinglepart_management(inFeatureClass, outFeatureClass)
 
    # Check if there is a different number of features in the output
    #   than there was in the input
    inCount = int(arcpy.GetCount_management(inFeatureClass).getOutput(0))
    outCount = int(arcpy.GetCount_management(outFeatureClass).getOutput(0))
    
    if inCount != outCount:
        # If there is a difference, print out the FID of the input 
        #   features which were multipart
        arcpy.Frequency_analysis(outFeatureClass,
                                 outFeatureClass + "_freq", "tmpUID")
 
        # Use a search cursor to go through the table, and print the tmpUID 
        print("Multipart features from {0}".format(inFeatureClass))
        for row in arcpy.da.SearchCursor(outFeatureClass + "_freq",
                                         ["tmpUID"], "FREQUENCY > 1"):
            print int(row[0])
    else:
        print("No multipart features were found")
except arcpy.ExecuteError:
    print arcpy.GetMessages()
except Exception as e:
    print e
