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 Coded Value To Domain

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

Summary

Adds a value to a domain's coded value list.

Usage

  • Domain management involves the following steps:

    1. Create the domain using the Create Domain tool.
    2. Add values to or set the range of values for the domain using this tool or the Set Value For Range Domain tool.
    3. Associate the domain with a feature class using the Assign Domain To Field tool.
  • The coded value domain includes both the actual value that is stored in the database (for example, 1 for pavement) and a description of what the code value means (for example, pavement).

  • A coded value domain which specifies a valid set of values for an attribute can apply to any type of attribute—text, numeric, date, and so on. For example, a coded value list for a text attribute might include valid pipe material values: CL - cast iron pipe; DL - ductile iron pipe; ACP - asbestos concrete pipe, or a coded value list might include the numeric values representing valid pipe diameters: .75–3/4"; 2–2"; 24–24"; and 30–30".

  • Workspace domains can also be managed in ArcCatalog or the Catalog window. Domains can be created and modified through the Domains tab on the Database Properties dialog box.

Syntax

AddCodedValueToDomain_management (in_workspace, domain_name, code, code_description)
ParameterExplanationData Type
in_workspace

The geodatabase containing the domain to be updated.

Workspace
domain_name

The name of the attribute domain that will have a value added to its coded value list.

String
code

The value to be added to the specified domain's coded value list.

String
code_description

A description of what the coded value represents.

String

Code sample

AddCodedValueToDomain Example (Python Window)

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

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.AddCodedValueToDomain_management("montgomery.gdb", "material", "1", "PVC")
AddCodedValueToDomain Example 2 (stand-alone script)

This stand-alone script uses the AddCodedValueToDomain function as part of a workflow to create an attribute domain and give it values.

# Name: MakeDomain.py
# Description: Create an attribute domain to constrain pipe material values
# 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"
 
    # Set local parameters
    domName = "Material4"
    gdb = "montgomery.gdb"
    inFeatures = "Montgomery.gdb/Water/Distribmains"
    inField = "Material"
 
    # Process: Create the coded value domain
    arcpy.CreateDomain_management("montgomery.gdb", domName, "Valid pipe materials", "TEXT", "CODED")
    
    # Store all the domain values in a dictionary with the domain code as the "key" and the 
    # domain description as the "value" (domDict[code])
    domDict = {"CI":"Cast iron", "DI": "Ductile iron", "PVC": "PVC", \
                "ACP": "Asbestos concrete", "COP": "Copper"}
    
    # Process: Add valid material types to the domain
    # use a for loop to cycle through all the domain codes in the dictionary
    for code in domDict:        
        arcpy.AddCodedValueToDomain_management(gdb, domName, code, domDict[code])
    
    # Process: Constrain the material value of distribution mains
    arcpy.AssignDomainToField_management(inFeatures, inField, domName)
 
except Exception as err:
    print(err.args[0])

Environments

  • Current Workspace
  • Auto Commit

Licensing information

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

Related topics

  • An overview of the Domains toolset
  • A quick tour of subtypes
  • A quick tour of attribute domains
  • Geoprocessing considerations for attribute domains

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