Union analysis fails to execute

3673
11
Jump to solution
09-13-2012 08:51 PM
RichardThurau
Occasional Contributor
Anyone see what's causing this tool to fail?


Gridnums = range(1,18)

for i in Gridnums:
    #vis6class = ws + "/" + "TVvis6class_G" + str(i)
    inList = arcpy.ListFeatureClasses("*ProcGrid_"+str(i), "")
    print "inList: " + str(inList)
    arcpy.Union_analysis(InList, ws + "/" + "TVvis6class_G" + str(i))


Error Code:
inList: [u'Road_ProcGrid_1', u'FPs_S_ProcGrid_1', u'er_di_ProcGrid_1', u'TV_v_ProcGrid_1']

Traceback (most recent call last):
  File "E:\Projects\TV\01_Python\LandCover\LC_2_Vector_Tile_6class_091312.py", line 48, in <module>
    arcpy.Union_analysis([InList], ws + "/" + "TVvis6class_G" + str(i))
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\analysis.py", line 483, in Union
    raise e
RuntimeError: Object: Error in executing tool
>>>



It's making a good list. I've tried messing with the output format.

Any suggestions, much appreciated!!

Rich
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RichardThurau
Occasional Contributor
Turns out I had an empty geography as one of my union inputs. When I tested the tool, it was within a study site where the geography had data. The first union the code was calling was using a dataset that had no data in the analysis area.

RT

View solution in original post

0 Kudos
11 Replies
ChristopherThompson
Occasional Contributor III
Out of curiousity what license level are you running? and how many items are in inList?  If you are at anything below the ArcInfo (or perhaps advanced i think is the new terminology.. ?) I don't think the union tool accepts more than two inputs.
0 Kudos
RichardThurau
Occasional Contributor
True. I am Info (advanced). Manually using the tool works fine, so error must be in the Python.

Thanks.

RT
0 Kudos
ChristopherThompson
Occasional Contributor III
I suspect they way the output is being created is your problem
ws + "/" + "TVvis6class_G" + str(i))

See if you can enclose that entire term inside double quotes and see if that works out.
So something like this might be what it looks like:
"'" + ws + "/" + "TVvis6class_G" + str(i)) + "'"
0 Kudos
RichardThurau
Occasional Contributor
No Dice. Took a while to get back to this.

Another one of these cases where a lot of people are looking but no one has any suggestions?

Am I doing something so fundamentally wrong that folks think it's hopeless?

Is there a better way to line this up that makes sense?

Is this really something that shouldn't be going wrong, but is?

Do I need to post more info? The error code is exceptionally meaningless in this case.

I really don't want to revert to using ArcToolbox. Please, please!

Current code:
for i in Gridnums:
    vis6classi = "'" + ws + "/" + "TVvis6class_G" + str(i) + "i" + "'"
    inList = arcpy.ListFeatureClasses("*ProcGrid_"+str(i), "")
    print "inList: " + str(inList)
    arcpy.Union_analysis(InList, vis6classi)
    print "Union completed for Grid " + str(i)


same error.

RT
0 Kudos
ThomasEmge
Esri Contributor
Please do print the variable vis6classi and take a look what it currently contains.

My guess would be that it is pointing to a location/workspace that isn't correctly formulated.

If you are able to post your complete script or a more extended section showing where the workspace originates that would be great.

Thanks,
- Thomas
0 Kudos
RichardThurau
Occasional Contributor
Turns out I had an empty geography as one of my union inputs. When I tested the tool, it was within a study site where the geography had data. The first union the code was calling was using a dataset that had no data in the analysis area.

RT
0 Kudos
ChristopherThompson
Occasional Contributor III
Don't you just hate that?  Glad you found the error!
0 Kudos
JamieKass
Occasional Contributor
I am getting the exact same error, but my input is just one feature class (in order to find overlapping regions). It is called within a Python Toolbox workflow, and consistently throws this error. When I run it outside the tool run session, it works fine. Maddening. Any clues as to what might be going on?
0 Kudos
JamieKass
Occasional Contributor
Just solved it. I never had this issue before, but perhaps this is a new limitation in 10.1? The input parameter to Union must be a list, at least in my case. I put the single input into a list, i.e.
arcpy.Union_analysis([input], output)
and my tool runs smoothly. If this is a hard rule, it should be emphasized in the tool help.