マルチパート → シングルパート(Multipart To Singlepart) (データの管理)
サマリ
入力のマルチパートフィーチャを分割して生成されたシングルパート フィーチャを格納する、フィーチャクラスを作成します。
図
![]() |
使用法
-
入力フィーチャの属性は、出力フィーチャクラスで維持されます。新しいフィールド、ORIG_FID が出力フィーチャクラスに追加され、入力フィーチャ ID に設定されます。
-
入力のマルチパート フィーチャの各パートは、出力フィーチャクラス内の個々のシングルパート フィーチャになります。すでにシングルパートになっているフィーチャは、影響を受けません。
-
出力フィーチャ タイプのほとんどは、入力と同じになります(入力ポリゴンはポリゴンのままで、入力ラインはラインのままです)。唯一の例外は、入力フィーチャがマルチポイント タイプのときは、出力フィーチャクラスがポイント タイプになるという点です。
-
ORIG_FID などの共通のフィールド値に基づいてシングルパート フィーチャからマルチパート フィーチャを再構成するには、[ディゾルブ(Dissolve)] ツールを使用します。
構文
MultipartToSinglepart_management (in_features, out_feature_class)
| パラメータ | 説明 | データ タイプ |
in_features |
入力フィーチャには、任意のフィーチャ タイプを指定できます。 | Feature Layer |
out_feature_class |
入力フィーチャ タイプに応じて異なるフィーチャを格納する、出力フィーチャクラス。 | Feature Class |
コードのサンプル
MultipartToSinglepart(マルチパート → シングルパート)の例 1(Python ウィンドウ)
次の Python ウィンドウ スクリプトは、イミディエイト モードで MultipartToSinglepart(マルチパート → シングルパート)関数を使用する方法を示しています。
import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.MultipartToSinglepart_management("landuse.shp",
"c:/output/output.gdb/landuse_singlepart")
MultipartToSinglepart(マルチパート → シングルパート)の例 2(スタンドアロン スクリプト)
次のスタンドアロン スクリプトは、スクリプト環境で MultipartToSinglepart(マルチパート → シングルパート)関数を適用する方法を示した単純な例です。
# 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
from arcpy import env
# Set environment settings
env.workspace = "C:/data/landcovers.gdb"
# Create variables for the input and output feature classes
inFeatureClass = "vegetation"
outFeatureClass = "vegetation_singlepart"
# Use error trapping in case a problem occurs when running the tool
try:
# 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
# Get the results of GetCount for input and output
resultIn = arcpy.GetCount_management(inFeatureClass)
resultOut = arcpy.GetCount_management(outFeatureClass)
if (resultIn.getOutput(0) == resultOut.getOutput(0)):
print "The number of features in the input is the same as in the output," +\
"so no multipart features were found"
else:
# If there is a difference, print out the FID of the input features
# which were multipart
arcpy.Frequency_analysis(outFeatureClass, outFeatureClass + "_freq",
"ORIG_FID")
# Use a search cursor to go through the table, and print the ORIG_FID
print "Here are the FIDs of all the multipart features from " + inFeatureClass
rows = arcpy.SearchCursor(outFeatureClass + "_freq", "\"FREQUENCY\" > 1")
row = rows.next()
while row:
print int(row.ORIG_FID)
row = rows.next()
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
環境
関連項目
ライセンス情報
ArcView: はい
ArcEditor: はい
ArcInfo: はい
7/10/2012
