サブタイプの追加(Add Subtype) (データ管理)
使用法
- 
新しいサブタイプを追加する前に、フィーチャクラスまたはテーブル内のフィールドをサブタイプ フィールドとして割り当てる必要があります。この操作には、[サブタイプ フィールドの設定(Set Subtype Field)] ツールを使用します。 
- 
すでに存在するコードを持つサブタイプを追加しようとしても、新しいサブタイプは無視されます。 
- 
既存のサブタイプの説明を変更する必要がある場合は、初めにそのサブタイプを削除してから、同じコードと新しい説明を使用して新しいサブタイプを追加してください。 
- 
フィーチャクラスまたはテーブルのサブタイプは、ArcCatalog で管理することも可能です。サブタイプの作成および変更は、データセットの プロパティ ダイアログ ボックスの サブタイプ プロパティ タブを使用して実行できます。 
構文
AddSubtype_management (in_table, subtype_code, subtype_description)
| パラメータ | 説明 | データ タイプ | 
| in_table | 更新するサブタイプ定義が含まれているフィーチャクラスまたはテーブル | Table View | 
| subtype_code | 追加するサブタイプに使用する一意の整数値 | Long | 
| subtype_description | サブタイプ コードの説明 | String | 
コードのサンプル
Add Subtype(サブタイプの追加)の例(Python ウィンドウ)
次の Python ウィンドウ スクリプトで、AddSubtype(サブタイプの追加)関数をイミディエイト モードで使用する方法を示します。
import arcpy
from arcpy import env
env.workspace = "C:/data/Montgomery.gdb"
arcpy.SetSubtypeField_management("water/fittings", "TYPECODE")
arcpy.AddSubtype_management("water/fittings", "1", "Bend")
Add Subtype(サブタイプの追加)の例 2(スタンドアロン スクリプト)
次のスタンドアロン スクリプトで、AddSubtype(サブタイプの追加)関数をワークフローの一部として使用して、フィールドにサブタイプを追加する方法を示します。
# Name: ManageSubtypes.py
# Purpose: Create a subtype definition
# Author: ESRI
# Import system modules
import arcpy
from arcpy import env
 
try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    env.workspace =  "C:/data/Montgomery.gdb"
    
    # Set local parameters
    inFeatures = "water/fittings"
 
    # Process: Set Subtype Field...
    arcpy.SetSubtypeField_management(inFeatures, "TYPECODE")
     
    # Process: Add Subtypes...
    # Store all the suptype values in a dictionary with the subtype code as the "key" and the 
    # subtype description as the "value" (stypeDict[code])
    stypeDict = {"0": "Unknown", "1": "Bend", "2": "Cap", "3": "Cross", "4": "Coupling",\
                 "5": "Expansion joint", "6": "Offset", "7":"Plug", "8": "Reducer",\
                 "9": "Saddle", "10": "Sleeve", "11": "Tap", "12": "Tee", "13": "Weld", "14": "Riser"} 
    
    # use a for loop to cycle through the dictionary
    for code in stypeDict:
        arcpy.AddSubtype_management(inFeatures, code, stypeDict[code])     
			
    # Process: Set Default Subtype...
    arcpy.SetDefaultSubtype_management(inFeatures, "4")
 
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
環境
関連トピック
ライセンス情報
ArcGIS for Desktop Basic: ○
ArcGIS for Desktop Standard: ○
ArcGIS for Desktop Advanced: ○
7/28/2014