摘要
根据属性域创建表。
用法
根据属性域创建一个表后,您便可以对该表执行其他编辑操作。例如,如果根据编码值属性域创建一个表,则其他编码值便可添加到此编码值列表中,并且还可以通过表转属性域工具更新原始属性域。
还可以在 ArcCatalog 或目录窗口中管理工作空间属性域。可通过数据库属性对话框中的属性域选项卡创建和修改属性域。
语法
DomainToTable_management (in_workspace, domain_name, out_table, code_field, description_field, {configuration_keyword})| 参数 | 说明 | 数据类型 | 
in_workspace  | 包含要转换为表的属性域的工作空间。  | Workspace | 
domain_name  | 现有属性域的名称。  | String | 
out_table  | 要创建的表。  | Table | 
code_field  | 已创建表中用于储存编码值的字段的名称。  | String | 
description_field  | 已创建表中用于储存编码值描述的字段的名称。  | String | 
configuration_keyword (可选)  | 用于创建地理数据库表的自定义存储关键字。  | String | 
代码实例
属性域转表示例(Python 窗口)
以下 Python 窗口脚本演示了如何在即时模式下使用 DomainToTable 函数。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.DomainToTable_management("montgomery.gdb", "DistDiam", "diameters", "code", "descript")
属性域转表示例 2(独立脚本)
该独立脚本将 DomainToTable 函数用作编辑属性域的工作流的一部分。
# Name: RemoveDomainsExample.py
# Purpose: Update an attribute domain to constrain valid pipe material values
# Import system modules
import arcpy
import os
 
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
    inFeatures = "Montgomery.gdb/Water/DistribMains"
    inField = "MATERIAL"
    dWorkspace = "Montgomery.gdb"
    domName = "Material"
    codedValue =  "ACP: Asbestos concrete"
    codeField = "TYPE"
    fieldDesc= "DESRIPT"
    # Process: Remove the constraint from the material field
    arcpy.RemoveDomainFromField_management(inFeatures, inField)
 
    # Edit the domain values
    # Process: Remove a coded value from the domain
    arcpy.DeleteCodedValueFromDomain_management(dWorkspace, domName, codedValue)
 
    # Process: Create a table from the domain to edit it with ArcMap editing tools
    arcpy.DomainToTable_management(dWorkspace, domname, dWorkspace + os.sep + domname , codeField, fieldDesc)
 
    # Process: Delete the domain
    arcpy.DeleteDomain_management(dWorkspace, domName)
 
    # Edit the domain table outside of geoprocessing
    # and then bring the domain back in with the TableToDomain process
 
except Exception as err:
    print(err.args[0])