union fuction using variable for input featureclass list

35 views
Skip to first unread message

GISChick

unread,
Jul 7, 2014, 12:23:08 PM7/7/14
to geop...@googlegroups.com

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?

Lew.Gr...@gov.bc.ca

unread,
Jul 9, 2014, 2:35:20 PM7/9/14
to geop...@googlegroups.com
Hi GISChick,
 
There a two scripts that have examples of unioning layers in from lists - one example has the list of layers read from a text file. 
P:\corp\script_whse\python\Analysis\In_Progress\Script_to_union_layers
Reply all
Reply to author
Forward
0 new messages