属性域转表 (数据管理)

摘要

根据属性域创建表。

使用情况

  • 通过属性域创建表可以对表进行额外的编辑。 例如,可以根据编码值域创建表,可以向编码值列表添加额外的代码值,并且可以使用表转属性域工具来更新原始域。

  • 还可以在属性域视图中管理属性域,可通过单击数据功能区中数据设计组内的属性域按钮将其打开。

参数

标注说明数据类型
输入工作空间

包含要转换为表的属性域的工作空间。

Workspace
属性域名称

现有属性域的名称。

String
输出表

要创建的表。

Table
编码字段

在创建的表中存储代码值的字段名称。

String
字段描述

在创建的表中存储代码值描述的字段名称。

String
配置关键字
(可选)

对于地理数据库表,用于创建表的自定义存储关键字。

String

arcpy.management.DomainToTable(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

代码示例

DomainToTable 示例(Python 窗口)

以下 Python 窗口脚本演示了如何使用 DomainToTable 函数。

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.DomainToTable("montgomery.gdb", "DistDiam", "diameters", "code", "descript")
DomainToTable 示例 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.management.RemoveDomainFromField(inFeatures, inField)
 
    # Edit the domain values
    # Process: Remove a coded value from the domain
    arcpy.management.DeleteCodedValueFromDomain(dWorkspace, domName, codedValue)
 
    # Process: Create a table from the domain
    arcpy.management.DomainToTable(dWorkspace, domname, dWorkspace + os.sep + domname , codeField, fieldDesc)
 
    # Process: Delete the domain
    arcpy.management.DeleteDomain(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])

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题