ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

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
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Set Subtype Field

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

Summary

Defines the field in the input table or feature class that stores the subtype codes.

Usage

  • A feature class or table can have only one subtype field.

  • After a subtype field is set, subtype codes can be added to the feature class or table using the Add Subtype tool.

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

  • This tool can also be used to clear the subtype field if a subtype field is no longer needed.

Syntax

SetSubtypeField_management (in_table, {field}, {clear_value})
ParameterExplanationData Type
in_table

The input table or feature class that contains the field to set as a subtype field.

Table View
field
(Optional)

The integer field that will store the subtype codes.

Field
clear_value
(Optional)

Specifies whether to clear the subtype field.

  • TRUE —The subtype field will be cleared (set to null).
  • FALSE —The subtype field will not be cleared. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_table

Code sample

SetSubtypeField example (Python window)

The following Python window script demonstrates how to use the SetSubtypeField function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data/Montgomery.gdb"
arcpy.SetSubtypeField_management("water/fittings", "TYPECODE")
SetSubtypeField example 2 stand-alone script)

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

# Name: ManageSubtypes.py
# Purpose: Create a subtype definition

# 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/Montgomery.gdb"

# Set local parameters
inFeatures = "water/fittings"

# Process: Set Subtype Field...
arcpy.SetSubtypeField_management(inFeatures, "TYPECODE")

# Process: Add Subtypes...
# Store all the subtype 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", "")
SetSubtypeField example 3 (Python window)

The following Python window script demonstrates how to use the SetSubtypeField function in immediate mode to clear the subtype field.

import arcpy
arcpy.env.workspace = "C:/data/Montgomery.gdb"
arcpy.SetSubtypeField_management("water/fittings", "", "TRUE")

Environments

  • Auto Commit
  • Current Workspace

Licensing information

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

Related topics

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

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

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

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2019 Esri. | Privacy | Legal