Добавить подтип (Add Subtype) (Управление данными)

Уровень лицензии:BasicStandardAdvanced

Резюме

Добавляет новый подтип к подтипам входной таблицы.

Более подробно о работе с подтипами

Использование

Синтаксис

AddSubtype_management (in_table, subtype_code, subtype_description)
ПараметрОбъяснениеТип данных
in_table

Класс пространственных объектов или таблица с установленным полем подтипов.

Table View
subtype_code

Уникальное целочисленное значение для добавляемого подтипа.

Long
subtype_description

Описание кода подтипа.

String

Пример кода

Добавить подтип. Пример (окно Python)

Пример скрипта Python для выполнения функции Добавить подтип (Add Subtype) с запуском из окна Python в ArcGIS.

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 (автономный скрипт)

Пример скрипта Python для выполнения функции Добавить подтип (Add Subtype) как часть рабочего потока, чтобы добавить подтипы к полю.

# 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/10/2013