描述
向属性域的编码值列表添加值。
使用方法
语法
AddCodedValueToDomain(in_workspace, domain_name, code, code_description)
参数 | 说明 | 数据类型 |
in_workspace | 包含要更新的属性域的地理数据库。 | Workspace |
domain_name | 向其编码值列表中添加值的属性域的名称。 | String |
code | 要添加到指定属性域的编码值列表的值。 | String |
code_description | 对编码值含义的描述。 | String |
派生输出
名称 | 说明 | 数据类型 |
out_workspace | 已更新的工作空间 | 工作空间 |
代码示例
以下 Python 窗口脚本演示了如何在即时模式下使用 AddCodedValueToDomain 函数。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.AddCodedValueToDomain_management("montgomery.gdb", "material", "1", "PVC")
此独立脚本将 AddCodedValueToDomain 函数用作工作流的一部分,以创建属性域并为其赋值。
# Name: MakeDomain.py
# Description: Create an attribute domain to constrain pipe material values
# Import system modules
import arcpy
# 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)
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是