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

Create Domain

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

Summary

Creates an attribute domain in the specified workspace.

Usage

  • Domain management involves the following steps:

    1. Create the domain using the this tool.
    2. Add values to or set the range of values for the domain using the Add Coded Value to Domain tool or Set Value For Range Domain tool.
    3. Associate the domain with a feature class using the Assign Domain To Field tool.
  • Coded value domains support only default value and duplicate split policies and default value merge policies.

  • Range domains support all split and merge policies. After a Split or Merge operation, the attribute values of output features are calculated based on the numeric values of the input features and the specified split or merge policy.

  • 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

CreateDomain_management (in_workspace, domain_name, {domain_description}, {field_type}, {domain_type}, {split_policy}, {merge_policy})
ParameterExplanationData Type
in_workspace

The geodatabase that will contain the new domain.

Workspace
domain_name

The name of the domain that will be created.

String
domain_description
(Optional)

The description of the domain that will be created.

String
field_type
(Optional)

The type of attribute domain to create. Attribute domains are rules that describe the legal values of a field type. Specify a field type that matches the data type of the field to which the attribute domain will be assigned.

  • SHORT —Numeric values without fractional values within a specific range; coded values. This is the default value.
  • LONG —Numeric values without fractional values within a specific range.
  • FLOAT —Numeric values with fractional values within a specific range.
  • DOUBLE —Numeric values with fractional values within a specific range.
  • TEXT —Names or other textual qualities.
  • DATE —Date and/or time.
String
domain_type
(Optional)

The domain type to create:

  • CODED —Specifies a valid set of values for an attribute. For example, a coded value domain might specify valid pipe material values: CL—cast iron pipe, DL—ductile iron pipe, or ACP—asbestos concrete pipe. This is the default value.
  • RANGE —Specifies a valid range of values for a numeric attribute. For example, if distribution water mains have a pressure between 50 and 75 psi, then a range domain would specify these minimum and maximum values.
String
split_policy
(Optional)

The split policy of the created domain. The behavior of an attribute's values when a feature that is split is controlled by its split policy.

  • DEFAULT —The attributes of the two resulting features take on the default value of the attribute of the given feature class or subtype.
  • DUPLICATE —The attribute of the two resulting features takes on a copy of the original object's attribute value.
  • GEOMETRY_RATIO —The attributes of resulting features are a ratio of the original feature's value. The ratio is based on the proportion into which the original geometry is divided. If the geometry is divided equally, each new feature's attribute gets one-half the value of the original object's attribute. The geometry ratio policy only applies to range domains.
String
merge_policy
(Optional)

The merge policy of the created domain. When two features are merged into a single feature, merge policies control attribute values in the new feature.

  • DEFAULT —The attribute of the resulting feature takes on the default value of the attribute of the given feature class or subtype. This is the only merge policy that applies to nonnumeric fields and coded value domains.
  • SUM_VALUES —The attribute of the resulting feature takes on the sum of the values from the original feature's attribute. The sum values policy only applies to range domains.
  • AREA_WEIGHTED —The attribute of the resulting feature is the weighted average of the attribute values of the original features. This average is based on the original feature's geometry. The area weighted policy only applies to range domains.
String

Code sample

Create Domain Example (Python Window)

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

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.CreateDomain_management("montgomery.gdb", "Materials", "Valid pipe materials", "TEXT", "CODED")
Create Domain Example 2 (Stand-alone Script)

This stand-alone script utilized the CreateDomain function as part of a workflow to create an attribute domain, assign values to it, and assign the domain to a field in a feature class.

# Name: MakeDomain.py
# Description: Create an attribute domain to constrain pipe material values
 
#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

  • Auto Commit
  • Current Workspace

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS 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 Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • 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