Listing Attribute Domains

The data access (arcpy.da) module in ArcGIS 10.1 delivers a function for listing attribute domains, whereby, you can retrieve all the properties for each domain. Here is an example of listing and describing all the attribute domains for a geodatabase:

import arcpy

domains = arcpy.da.ListDomains("C:/Boston/Boston.gdb")
for domain in domains:
    print('Domain name: {0}'.format(domain.name))
    if domain.domainType == 'CodedValue':
        coded_values = domain.codedValues
        for val, desc in coded_values.iteritems():
            print('{0} : {1}'.format(val, desc))
    elif domain.domainType == 'Range':
        print('Min: {0}'.format(domain.range[0]))
        print('Max: {0}'.format(domain.range[1]))

To copy domains from one geodatabase to another, copy the function from the following location:
https://gist.github.com/1877237

One thought on “Listing Attribute Domains

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s