I am having issues getting Union to work from Python as it doesn’t seem to like my first argument which is a list of layers to input into the tool.
I have previously done this via script by converting a list to a tuple with ; separating each item, but now that doesn’t seem to be working for me. Not sure if something has changed in 10.1 or what?
Currently I’m trying this:
#Create list of layers to union (one or more of these feature classes may not exist so have to create the list based on the layers that are present)
unionlist = []
if arcpy.Exists(cutBlks_clip):
unionlist.append('cutBlks_clip')
if arcpy.Exists(NewLogging):
unionlist.append('NewLogging')
if arcpy.Exists(HBStatusBlks):
unionlist.append('HBStatusBlks')
#Remove quotes from list for input to union (input list can't have quotes around each item)
unionlist = str(unionlist)
unionlist = unionlist.replace("'","")
print unionlist
#Union all Depletion layers
arcpy.Union_analysis(unionlist, Deplete, "ALL")
It’s giving an error on the Union: RuntimeError: Object: Error in executing tool
The contents of my list, unionlist prints to the screen and looks correct: [cutBlks_clip, NewLogging, HBStatusBlks]
If I re-run the union command manually and replace my variable unionlist with the list above the command executes no problem but for some reason it will not work as a variable.
This is driving me bonkers! Can anyone tell me what I'm missing here?