A error in my previously-smooth-running arcpy script has me confounded. The error occurs where the script selects individual features in two different feature classes, and then performs an Erase function.
It seems to be working fine for the first one or two files that it erases, but then stops with "Error 000210: Cannot create output."
Using arcpy.GetMessages gives greater detail...
ERROR 000210: Cannot create output The XML being loaded could not be parsed. [GDB_Items] The XML being loaded could not be parsed. [XML document must have a top level element. XML document must have a top level element.
The only useful info online I've found suggested restarting the script each time it fails, which works - in that I restart, and the script moves on to the next item in line to be processed .
This is (most of) the offending script, and I've highlight where the Error is coming from:
import arcpy
from arcpy import env
import time
from time import strftime
#Set overwrite output
arcpy.env.overwriteOutput = True
print arcpy.env.overwriteOutput
donutlog = "C:\\BOEM\\Donuts\\donut_log.txt"
workspace = "C:\\BOEM\\pt_buff2\\"
fileList = []
buffersd4 = []
buffersd3 = []
buffs = workspace+"buffer.gdb"
directorypath = buffs
#Insert test to see if ID was done around here:
finishedIDs = {}
FClist = []
with open(donutlog) as f:
for line in f:
if line.startswith("Executing"):
FCname=line.split(' ')
FClist.append(FCname[2][:-4])
for dirpath, dirnames, fgdb in arcpy.da.Walk(directorypath,
datatype="FeatureClass",
type="Polygon"):
for fc in fgdb:
fc_split=fc.split('_')
StartTime=time.clock()
if fc.endswith("d4"):
if fc in FClist:
print fc + " has already been looked at!"
else:
#list features by APR16_ID in that fc
APR16_ID4 = [row[0] for row in arcpy.da.SearchCursor(buffs+"\\"+fc,['APR16_ID'])]
# make feat layer of fc_endswith_d4
in_feat4 = buffs+"\\"+fc
out_layer4 = fc+"_lyr"
arcpy.MakeFeatureLayer_management(in_feat4,out_layer4)
print "Make Feature Layer for " + fc
#make feat layer of fc_endswith_d3
in_feat3 = buffs +"\\"+ fc[:-2]+"d3"
out_layer3 = fc[:-2]+"d3"
arcpy.MakeFeatureLayer_management(in_feat3, out_layer3)
print "Make Feature Layer for " + in_feat3
### ERROR IN THIS SECTION ####
for ID4 in APR16_ID4:
where_clause4=""" "APR16_ID" = """ + "'"+ID4+"'"
arcpy.SelectLayerByAttribute_management(out_layer4,"NEW_SELECTION",where_clause4)
arcpy.SelectLayerByAttribute_management(out_layer3,"NEW_SELECTION",where_clause4)
erase_out= "C:\\BOEM\\Donuts\\Donuts_d4_output.gdb\\"+"don_d4_"+ID4
### Error in the Erase function here:
arcpy.Erase_analysis(out_layer4, out_layer3,erase_out,"")
print "Erase "+ out_layer3 +" from "+out_layer4+" to produce "+erase_out
print arcpy.GetMessages()
print "___"