ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Add Subtype

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Adds a new subtype to the subtypes in the input table.

Learn more about working with subtypes

Usage

  • A field in the feature class or table must be assigned as the subtype field before new subtypes can be added. This is done using the Set Subtype Field tool.

  • If you add a subtype whose code already exists, the new subtype will be ignored.

  • If you need to change the description of an existing subtype, you would first have to remove the subtype, then add a new subtype with the same code and a new description.

  • The subtypes of a feature class or table can also be managed in ArcCatalog. Subtypes can be created and modified using the Subtypes Property tab on the dataset's Properties dialog box.

Syntax

AddSubtype_management (in_table, subtype_code, subtype_description)
ParameterExplanationData Type
in_table

The feature class or table containing the subtype definition to be updated

Table View
subtype_code

A unique integer value for the subtype to be added

Long
subtype_description

A description of the subtype code

String

Code sample

Add Subtype example (Python window)

The following Python window script demonstrates how to use the AddSubtype function in Immediate mode.

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")
Add Subtype example 2 (Stand-alone script)

The following stand-alone script demonstrates how to use the AddSubtype function as part of a workflow to add subtypes to a field.

# 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])

Environments

  • Auto Commit
  • Current Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Subtypes toolset
  • Geoprocessing considerations for subtypes
  • Geoprocessing workflow for subtypes
  • Working with subtypes

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal