设置子类型字段 (Data Management)
摘要
为存储子类型编码的输入表或要素类定义字段。
用法
-
要素类或表只能具有一个子类型字段。
-
设置子类型字段后,可使用添加子类型工具将子类型编码添加到要素类或表中。
-
此外,还可以在 ArcCatalog 中对要素类或表的子类型进行管理。使用数据集“属性”对话框中的“子类型属性”页面可以创建和修改子类型。
语法
SetSubtypeField_management (in_table, field)
参数 | 说明 | 数据类型 |
in_table |
包含要设置为子类型字段的字段的输入表或要素类。 | Table View |
field |
将存储子类型编码的整型字段。 | Field |
代码实例
设置子类型字段示例(Python 窗口)
以下 Python 窗口脚本演示了如何在立即模式下使用 SetSubtypeField 函数。
import arcpy from arcpy import env env.workspace = "C:/data/Montgomery.gdb" arcpy.SetSubtypeField_management("water/fittings", "TYPECODE")
置子类型字段示例 2(独立脚本)
以下独立脚本演示了如何在将子类型添加到字段的工作流中使用 SetSubtypeField 函数。
# Name: ManageSubtypes.py # Purpose: Create a subtype definition # Author: ESRI # Import system modules import arcpy from arcpy import env try: # Set the workspace (to avoid having to type in the full path to the data every time) 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, e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info()[2] print "Line %i" % tb.tb_lineno print e.message
相关主题
许可信息
ArcGIS for Desktop Basic:是
ArcGIS for Desktop Standard:是
ArcGIS for Desktop Advanced:是
9/15/2013