Runtime Error with arcpy.Union_analysis()

336
5
10-17-2018 08:39 AM
JustinBridwell2
Occasional Contributor II

I am trying to run a union on a feature class (master_merge_footprints_20181011) and 2 temporary layers made from selected features (using select by attributes and then create layer from selection) from shapefiles (Prelim_S_Fld_Haz_Ar_13245 and  S_Fld_Haz_Ar)  

Here's the code snippet from the result (which worked):

arcpy.Union_analysis(in_features="Prelim_S_FLD_HAZ_AR_0637 #;Prelim_S_Fld_Haz_Ar_13245 #;'S_Fld_Haz_Ar selection' #;master_merge_footprints_20181011 #", out_feature_class="C:/Users/jbridwell/Documents/ArcGIS/Default.gdb/New_FLD_HAZ_AR_Union", join_attributes="ALL", cluster_tolerance="", gaps="NO_GAPS")

However, when I try a similar process in my script, I keep getting RuntimeError: Object: Error in executing tool. I though there might be a lock or something network related (the files are from a folder connection in a network drive) on one of the files, so I restarted my whole computer, but that was not the issue. Here is the traceback and the relevant portion of the code. Does anyone have any ideas as to what the problem might be or how to get it to run? Note: both 

Traceback: 

In [29] wkflw2_union = arcpy.Union_analysis(["master_merge_20181011", nfhl_fld_haz_features], "wkflw2_union_output", "ALL")

Traceback (most recent call last):

File "<ipython-input-28-37797fd2b95a>", line 1, in <module>
wkflw2_union = arcpy.Union_analysis(["master_merge_20181011", nfhl_fld_haz_features], "wkflw2_union_output", "ALL")

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\analysis.py", line 734, in Union
raise e

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\analysis.py", line 731, in Union
retval = convertArcObjectToPythonObject(gp.Union_analysis(*gp_fixargs((in_features, out_feature_class, join_attributes, cluster_tolerance, gaps), True)))

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 496, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))

RuntimeError: Object: Error in executing tool

Code:

wkflw2_union_output = "C:/Workspace/Sandbox/MapChangeProject/master_Map_Change_Report_App/gdb/selects.gdb/wkflw2_union_{}".format(today)
master_merge = "C:/Workspace/Sandbox/MapChangeProject/master_Map_Change_Report_App\gdb\selects.gdb\master_merge_footprints_{}".format(today)
wkflw2_union = arcpy.Union_analysis([master_merge, nfhl_fld_haz_features, prelim_fld_haz_features], wkflw2_union_output)

0 Kudos
5 Replies
DanPatterson_Retired
MVP Esteemed Contributor

how are you arriving at "today"

when I use 

td = datetime.datetime.now()

td2 = datetime.datetime.today()

td
datetime.datetime(2018, 10, 17, 16, 22, 13, 855834)

td2
datetime.datetime(2018, 10, 17, 16, 22, 18, 956293)

I get the time portion and I see that you don't... ie

'C:/Workspace/Sandbox/MapChangeProject/master_Map_Change_Report_App/gdb/selects.gdb/wkflw2_union_2018-10-17 16:17:59.888924'

or is your 'today' different

JustinBridwell2
Occasional Contributor II

Oh, sorry. I didn't include that because it didn't seem relevant but it's at the top under my `import` statements:

today = datetime.datetime.today().strftime('%Y%m%d')

which returns a tring:

Out[1] '20181017'

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You use forward slashes for the main part of you paths

"C:/Workspace/Sandbox/MapChangeProject/master_Map_Change_Report_App

but then switchup for the trailing bits, have you confirmed that that isn't confusing things

/gdb/selects.gdb/wkflw2_union_

\gdb\selects.gdb\master_merge_footprints_{}

JustinBridwell2
Occasional Contributor II

Nope. Same results. Could this be related to the geometry of the temp layers?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

at this stage, I would try to move the layers out of temp until you can confirm