サマリー
指定のワークスペースで属性ドメインを作成します。
使用法
- ドメイン管理は次の手順で行います。 - このツールでドメインを作成します。
- [ドメインにコード値を追加 (Add Coded Value To Domain)] ツールまたは [範囲ドメインの値を設定 (Set Value For Range Domain)] ツールを使用して、値をドメインに追加するか、ドメインの値の範囲を設定します。
- [フィールドへのドメインの割り当て (Assign Domain To Field)] ツールを使って、ドメインをフィーチャクラスに関連付けます。
 
- コード値ドメインでは、デフォルト値および複製のスプリット ポリシーとデフォルト値のマージ ポリシーのみがサポートされます。 
- 範囲ドメインでは、すべてのスプリット ポリシーとマージ ポリシーがサポートされます。スプリットまたはマージ操作後、入力フィーチャの数値と指定のスプリットまたはマージ ポリシーに基づいて出力フィーチャの属性値が計算されます。 
- ワークスペース ドメインは、ArcCatalog またはカタログ ウィンドウでも管理できます。[データベース プロパティ] ダイアログ ボックスの [ドメイン] タブを使用して、ドメインを作成および変更できます。 
構文
CreateDomain_management (in_workspace, domain_name, {domain_description}, {field_type}, {domain_type}, {split_policy}, {merge_policy})| パラメーター | 説明 | データ タイプ | 
| in_workspace | 新しいドメインが格納されるジオデータベース。 | Workspace | 
| domain_name | 作成されるドメインの名前。 | String | 
| domain_description (オプション) | 作成されるドメインの説明。 | String | 
| field_type (オプション) | 作成する属性ドメインのタイプ。属性ドメインとは、フィールド タイプの適正な値を規定するルールです。属性ドメインの割当先となるフィールドのデータ タイプに一致するフィールド タイプを指定します。 
 | String | 
| domain_type (オプション) | 作成するドメイン タイプ。 
 | String | 
| split_policy (オプション) | 作成されたドメインのスプリット ポリシー。フィーチャを分割するときの属性値の振舞いは、属性のスプリット ポリシーによって制御されます。 
 | String | 
| merge_policy (オプション) | 作成されたドメインのマージ ポリシー。2 つのフィーチャを 1 つのフィーチャにマージする際には、マージ ポリシーが新規フィーチャの属性値を制御します。 
 | String | 
コードのサンプル
Create Domain (ドメインの作成) の例 (Python ウィンドウ)
次の Python ウィンドウ スクリプトは、イミディエイト モードで DeleteCodedValueFromDomain (ドメインからコード値を削除) 関数を使用する方法を示しています。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.CreateDomain_management("montgomery.gdb", "Materials", "Valid pipe materials", "TEXT", "CODED")
Create Domain (ドメインの作成) の例 2 (スタンドアロン スクリプト)
次のスタンドアロン スクリプトでは、ワークフローの一部として CreateDomain (ドメインの作成) 関数を使って属性ドメインを作成し、値をそのドメインに割り当て、ドメインをフィーチャクラスのフィールドに割り当てます。
# Name: MakeDomain.py
# Description: Create an attribute domain to constrain pipe material values
 
#Import system modules
import arcpy
 
try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    arcpy.env.workspace = "C:/data"
 
    # Set local parameters
    domName = "Material4"
    gdb = "montgomery.gdb"
    inFeatures = "Montgomery.gdb/Water/Distribmains"
    inField = "Material"
 
    # Process: Create the coded value domain
    arcpy.CreateDomain_management("montgomery.gdb", domName, "Valid pipe materials", "TEXT", "CODED")
    
    #Store all the domain values in a dictionary with the domain code as the "key" and the 
    #domain description as the "value" (domDict[code])
    domDict = {"CI":"Cast iron", "DI": "Ductile iron", "PVC": "PVC", \
                "ACP": "Asbestos concrete", "COP": "Copper"}
    
    # Process: Add valid material types to the domain
    #use a for loop to cycle through all the domain codes in the dictionary
    for code in domDict:        
        arcpy.AddCodedValueToDomain_management(gdb, domName, code, domDict[code])
    
    # Process: Constrain the material value of distribution mains
    arcpy.AssignDomainToField_management(inFeatures, inField, domName)
 
except Exception as err:
    print(err.args[0])
環境
ライセンス情報
- ArcGIS Desktop Basic: はい
- ArcGIS Desktop Standard: はい
- ArcGIS Desktop Advanced: はい