标注 | 说明 | 数据类型 |
输入要素 | 输入要素可以是任何要素类型。 | Feature Layer |
输出要素类 | 输出要素类包含基于输入要素类型变化的要素。 | Feature Class |
摘要
通过分离多部件输入要素来创建单部件要素类。
插图
使用情况
输入要素的属性将保留在输出要素类中。向输出要素类添加新字段 ORIG_FID,并设置为输入要素 ID。
多部件要素的各个部件在输出要素类中将成为独立的要素。 已经是单部件的要素将不受影响。
大多数输出要素的类型与输入要素的类型相同(输入面仍为面;输入线仍为线)。 如果输入要素是多点类型,则输出要素类别将是点类型。
要使用单部件要素根据公用字段值重新构建多部件要素(例如 ORIG_FID),请使用融合工具。
多面体要素将被分为其构成的几何部件。 每一部件可定义为包含 x 、y 和 z 坐标的折点集合,其形式如下所示:
- 引用 3 个折点的单个三角形。
- 三角条带由共享同一条公用边的多个三角形定义。
- 三角扇由具有公用原点的多个三角形定义。
- 表示由 4 个或更多折点定义边界的共平面区域的圆环。
参数
arcpy.management.MultipartToSinglepart(in_features, out_feature_class)
名称 | 说明 | 数据类型 |
in_features | 输入要素可以是任何要素类型。 | Feature Layer |
out_feature_class | 输出要素类包含基于输入要素类型变化的要素。 | Feature Class |
代码示例
以下 Python 窗口脚本演示了如何在即时模式下使用 MultipartToSinglepart 函数。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.MultipartToSinglepart("landuse.shp",
"c:/output/output.gdb/landuse_singlepart")
以下独立脚本是演示如何在脚本环境中应用 MultipartToSinglepart 函数的简单示例。
# Name: MultipartToSinglepart_Example2.py
# Description: Break all multipart features into singlepart features,
# and report which features were separated.
# 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 that will be used as a unique identifier
arcpy.management.AddField(inFeatureClass, "tmpUID", "double")
# Determine what the name of the Object ID is
OIDFieldName = arcpy.Describe(inFeatureClass).OIDFieldName
# Calculate the tmpUID to the OID
arcpy.management.CalculateField(inFeatureClass, "tmpUID",
f"!{OIDFieldName}!", "PYTHON3")
# Run the tool to create a new fc with only singlepart features
arcpy.management.MultipartToSinglepart(inFeatureClass, outFeatureClass)
# Check if there is a different number of features in the output
# than there was in the input
inCount = int(arcpy.management.GetCount(inFeatureClass)[0])
outCount = int(arcpy.management.GetCount(outFeatureClass)[0])
if inCount != outCount:
# If there is a difference, print the FID of the input
# features that were multipart
arcpy.analysis.Frequency(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 err:
print(err.args[0])
环境
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是