サマリー
特定のフィールドおよび必要に応じてサブタイプにドメインを設定します。サブタイプを指定しなかった場合は、指定したフィールドのみにドメインが割り当てられます。
使用法
- ドメイン管理は次の手順で行います。 - [ドメインの作成 (Create Domain)] ツールを使って、ドメインを作成します。
- [ドメインにコード値を追加 (Add Coded Value To Domain)] ツールまたは [範囲ドメインの値を設定 (Set Value For Range Domain)] ツールを使用して、値をドメインに追加するか、ドメインの値の範囲を設定します。
- [フィールドへのドメインの割り当て (Assign Domain To Field)] ツール (このツール) を使用して、ドメインをフィーチャクラスに関連付けます。
 
- 属性ドメインをテーブルまたはフィーチャクラスに関連付けると、データベースに属性の整合性ルールが作成されます。この属性の整合性ルールにより、フィールド タイプに有効な値が指定および制限されます。 
- 1 つの属性ドメインを複数のフィールドに関連付けることができます。これは、同じテーブル、フィーチャクラス、サブタイプ内だけでなく、複数のテーブルやフィーチャクラス内でも可能です。 
- [入力テーブル] パラメーターには、フィーチャ レイヤーまたはテーブル ビューを指定できます。 
- ワークスペース ドメインは、ArcCatalog またはカタログ ウィンドウでも管理できます。[データベース プロパティ] ダイアログ ボックスの [ドメイン] タブを使用して、ドメインを作成および変更できます。 
- [サブタイプ] パラメーターの [値の追加] ボタンは、ModelBuilder 専用です。ModelBuilder では、先のツールが実行されていないか、出力データが存在しないために、[サブタイプ] パラメーターに値が表示されない場合があります。[値の追加] ボタンを使用すると、[フィールドへのドメインの割り当て (Assign Domain To Field)] ダイアログを完了してモデルの作成を続行できるように、必要な値が追加されます。 
構文
AssignDomainToField_management (in_table, field_name, domain_name, {subtype_code})| パラメーター | 説明 | データ タイプ | 
| in_table | ドメインを割り当てるフィールドが含まれているテーブルまたはフィーチャクラスの名前 | Table View | 
| field_name | ドメインを割り当てるフィールドの名前 | Field | 
| domain_name | フィールド名に割り当てるジオデータベース ドメインの名前。使用可能なドメインが自動的に読み込まれます。 | String | 
| subtype_code [subtype_code,...] (オプション) | ドメインを割り当てるサブタイプのコード | String | 
コードのサンプル
Assign Domain to Field (フィールドへのドメインの割り当て) の例 (Python ウィンドウ)
次の Python ウィンドウ スクリプトで、AssignDomainToField (フィールドへのドメインの割り当て) 関数をイミディエイト モードで使用する方法を示します。
import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.AssignDomainToField_management("montgomery.gdb/Landbase/Parcels", "ZONING_S", "ZoningFields", "1: government")
Assign Domain to Field (フィールドへのドメインの割り当て) の例 2 (スタンドアロン スクリプト)
次のスクリプトでは、AssignDomainToField (フィールドへのドメインの割り当て) 関数をワークフローの一部として使用することにより、属性ドメインを作成し、このドメインに値を割り当て、このドメインをフィールドに割り当てます。
# 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: はい