Created
May 7, 2014 07:21
-
-
Save sshopov/554c886b336fa2105991 to your computer and use it in GitHub Desktop.
It's hard to easily go over 400+ geodatabase domains using ArcCatalog. This script has methods to: exports all domains and their values in alphabetical order to text file for easier browsing; find a specific domain; print domain usage for all fields in a given dataset; . Tags: ArcGIS arcpy GIS esri
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
def export_domains_to_txt(): | |
lines = [] | |
for domain in arcpy.da.ListDomains(arcpy.env.workspace): | |
if domain.codedValues: | |
values = ','.join(['%s:%s'%(key, domain.codedValues[key]) for key in sorted(domain.codedValues.keys())]) | |
else: | |
values = domain.range | |
lines.append('%s : %s'%(domain.name, values)) | |
with file(r'domains.txt','w') as f: | |
f.write('\n'.join(sorted(lines))) | |
def get_domain(name): | |
domains = arcpy.da.ListDomains(arcpy.env.workspace) | |
for domain in domains: | |
if name.lower() == domain.name.lower(): | |
return domain | |
return None | |
def print_domain_usage(feature_dataset=''): | |
for fc in arcpy.ListFeatureClasses(feature_dataset=feature_dataset): | |
print fc | |
for field in arcpy.ListFields(fc): | |
if field.domain: | |
print '\t',field.name, field.domain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment