Export coded value domains

المشرف العام

Administrator
طاقم الإدارة
I've attempted to write a script that will export all the coded value domains in a geodatabase to a table. Before I dig in the to script and what's wrong, I have looked at the similar question on this topic, but that script would not run for me. Here is my code:

import arcpyarcpy.env.workspace = r"F:\ITree"gdb = r"ITree.gdb"arcpy.env.overwriteOutput = Truedomains = arcpy.da.ListDomains(gdb)for domain in domains: if domain.domainType == 'CodedValue': domain_name = domain.name print 'Exporting {0} coded values to table in {1}'.format(domain_name, gdb) coded_value_list = domain.codedValues print "The coded values / descriptions are" for value, descrip in coded_value_list.iteritems(): print "{0} : {1}".format(value, descrip) out_table_name = domain_name.lower() #arcpy.DomainToTable_management(gdb, domain_name, out_table_name, "item", "descrip") else: print "{0} not a coded value domain. Passing it up.".format(domain.name)When I comment out the Domain to Table, the script runs and produces, this:

Exporting LANDUSE coded values to table in ITree.gdbThe coded values / descriptions are1 : Single family residential0 : Not entered3 : Small commercial2 : Multi-family residential5 : Park/vacant/other4 : Industrial/Large commercialHowever, when I uncomment the Domain to Table, it produces the following error:

Exporting LANDUSE coded values to table in ITree.gdbThe coded values / descriptions are1 : Single family residential0 : Not entered3 : Small commercial2 : Multi-family residential5 : Park/vacant/other4 : Industrial/Large commercialTraceback (most recent call last): File "E:/Work/MDC/GISData/MOTools/Scripts/export_gdb_domains.py", line 29, in arcpy.DomainToTable_management(gdb, domain_name, out_table_name, "item", "descrip") File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 1491, in DomainToTable raise earcgisscripting.ExecuteError: ERROR 999999: Error executing function.Failed to execute (DomainToTable).It also produces the first table from the domain, but does not copy the coded values and creates an empty table. I've looked through the help documents for Domain to Table (Data Management) and List Domains, but I cannot figure out why it's throwing an error. Clearly something is off in the Domain to Table function, but I can't figure out what, especially since it prints all the parameters correctly. I would greatly appreciate any suggestions. Thank you for your time.



أكثر...
 
أعلى