Last active
March 17, 2022 10:09
-
-
Save danikane/bbe46b85e67e99035e8dac92bb244536 to your computer and use it in GitHub Desktop.
ArcGIS Sort Domains
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
# coding: utf8 | |
# Import modules | |
import arcpy | |
from datetime import datetime | |
# Local variables | |
gdb_conn = r"C:\..\GIS.sde" | |
# Sort domains | |
print(datetime.now().time()) | |
print("Sorting domains ...") | |
print("\n") | |
# Get a list of domains to sort | |
arcpy.env.workspace = gdb_conn | |
domains = arcpy.da.ListDomains() | |
for domain in domains: | |
#print('Domain name: {0}'.format(domain.name)) | |
if domain.domainType == 'CodedValue': | |
print("Target domain: " + domain.name) | |
try: | |
arcpy.SortCodedValueDomain_management(gdb_conn, domain.name, "DESCRIPTION", "ASCENDING") | |
except: | |
print("There was a failure sorting the domain") | |
finally: | |
print(arcpy.GetMessages()) | |
elif domain.domainType == 'Range': | |
print("Target domain: " + domain.name) | |
print("No sorting for ranged domains") | |
# Sort domains | |
print(datetime.now().time()) | |
print("Domains sorted") | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment