描述
将新的子类型添加到输入表的子类型中。
使用方法
语法
arcpy.management.AddSubtype(in_table, subtype_code, subtype_description)
参数 | 说明 | 数据类型 |
in_table | 要更新的子类型定义所在的要素类或表 | Table View |
subtype_code | 要添加子类型的唯一整数值 | Long |
subtype_description | 子类型编码描述 | String |
代码示例
“添加子类型”示例(Python 窗口)
以下 Python 窗口脚本演示了在即时模式下如何使用 AddSubtype 函数。
import arcpy
from arcpy import env
env.workspace = "C:/data/Montgomery.gdb"
arcpy.SetSubtypeField_management("water/fittings", "TYPECODE")
arcpy.AddSubtype_management("water/fittings", "1", "Bend")
“添加子类型”示例 2(独立脚本)
以下独立脚本演示了如何使用作为工作流一部分的 AddSubtype 函数,将子类型添加到字段中。
# Name: ManageSubtypes.py
# Purpose: Create a subtype definition
# Author: ESRI
# 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/Montgomery.gdb"
# Set local parameters
inFeatures = "water/fittings"
# Process: Set Subtype Field...
arcpy.SetSubtypeField_management(inFeatures, "TYPECODE")
# Process: Add Subtypes...
# Store all the suptype values in a dictionary with the subtype code as the "key" and the
# subtype description as the "value" (stypeDict[code])
stypeDict = {"0": "Unknown", "1": "Bend", "2": "Cap", "3": "Cross", "4": "Coupling",\
"5": "Expansion joint", "6": "Offset", "7":"Plug", "8": "Reducer",\
"9": "Saddle", "10": "Sleeve", "11": "Tap", "12": "Tee", "13": "Weld", "14": "Riser"}
# use a for loop to cycle through the dictionary
for code in stypeDict:
arcpy.AddSubtype_management(inFeatures, code, stypeDict[code])
# Process: Set Default Subtype...
arcpy.SetDefaultSubtype_management(inFeatures, "4")
except Exception as err:
print(err.args[0])
环境
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是