Select to view content in your preferred language

Errors in GP Tool when executed within C# application

503
2
11-02-2022 08:34 AM
MarniFowler
Emerging Contributor

I have a custom geoprocessing task written for me in python that takes 2 inputs - input_rows.csv and event_rows.csv - and creates a file gdb with a feature class of a join of these 2 tables.

input_rows has the x,y coordinates for the feature class. event_rows.csv contains the attributes.

When I run it locally in ArcCatalog (10.7.1), it runs fine. If I publish it to our ArcGIS 10.81 Linux server and run that in ArcCatalog, it also runs fine. If I try to execute it thru a call in my C# application, I get a generic error on TableToTable_conversion:

<Msg time='2022-10-25T13:01:43,305' type='SEVERE' code='20010' target='export/Download_v3.GPServer' methodName='GPServerSync.CheckMessages' machine='xxx' process='116658' thread='505' user='null'  requestId='xxx'>Error executing tool. Download Job ID: j46c9f46dd97642e4890778604255a1fb : 
Traceback (most recent call last):
  File "<string>", line 248, in execute
  File "<string>", line 190, in zip_GIS
  File "z:\home\esri\arcgis\server\arcpy\arcpy\conversion.py", line 2272, in TableToTable
    raise e
ExecuteError: ERROR 999999: Error executing function.
Failed to execute (TableToTable).

Here is the code to do the conversion:

x_coords = "S4_X"
y_coords = "S4_Y"
out_event_lyr = "event_layer"

v_scratchFolder_ = "%scratchFolder%"

# create Folder
arcpy.CreateFolder_management(v_scratchFolder_, "Geodatabase")

# create File GDB
arcpy.CreateFileGDB_management(x, gdb_name)

wkt = "PROJCS['NAD_1983_HARN_Florida_GDL_Albers',GEOGCS['GCS_North_American_1983_HARN',DATUM['D_North_American_1983_HARN',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-84.0],PARAMETER['Standard_Parallel_1',24.0],PARAMETER['Standard_Parallel_2',31.5],PARAMETER['Latitude_Of_Origin',24.0],UNIT['Meter',1.0],AUTHORITY['EPSG',3087]]"
sr = arcpy.SpatialReference()
sr.loadFromString(wkt)

out_event_lyr = arcpy.MakeXYEventLayer_management(input_rows, x_coords, y_coords, out_event_lyr, sr)
crash_fc = arcpy.CopyFeatures_management(out_event_lyr, os.path.join("%scratchFolder%\Geodatabase", gdb_name, out_event_fc))

event_tab = arcpy.TableToTable_conversion(event_rows, os.path.join("%scratchFolder%\Geodatabase", gdb_name), "EventTab")

crash_fc_lyr = arcpy.MakeFeatureLayer_management(crash_fc, "fc_lyr")
out_event_lyr_join = arcpy.AddJoin_management(crash_fc_lyr, "REPORT_NUMBER", event_tab, "REPORT_NUMBER")

arcpy.CopyFeatures_management(out_event_lyr_join, os.path.join("%scratchFolder%\Geodatabase", gdb_name, out_event_fc1))

We changed the script to do a CopyFeatures instead of TableToTable to see if that would work but I get a different error:

ExecuteError: ERROR 000210: Cannot create output Z:\opt\esri\arcgis\server\usr\directories\arcgisjobs\export\download_v3_1_gpserver\j46744155824f44e1ad5f7c1a1a6afc71\scratch\Geodatabase\s4_mapped_crashes_gdb.gdb\att
Failed to execute (CopyFeatures).

Here is the CopyFeature version:

x_coords = "S4_X"
y_coords = "S4_Y"
out_event_lyr = "event_layer"

v_scratchFolder_ = "%scratchFolder%"
Geodatabase = v_scratchFolder_
s4_crash_gdb_gdb = Geodatabase

# create Folder
x = arcpy.CreateFolder_management(v_scratchFolder_, "Geodatabase")
arcpy.AddMessage(x)

# create File GDB
arcpy.CreateFileGDB_management(x, gdb_name)

wkt = "PROJCS['NAD_1983_HARN_Florida_GDL_Albers',GEOGCS['GCS_North_American_1983_HARN',DATUM['D_North_American_1983_HARN',SPHEROID['G RS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-84.0],PARAMETER['Standard_Parallel_1',24.0],PARAMETER['Standard_Parallel_2',31.5],PARAMETER['Latitude_Of_Origin',24.0],UNIT['Meter',1.0],AUTHORITY['EPSG',3087]]"
sr = arcpy.SpatialReference()
sr.loadFromString(wkt)

# create GIS file in geodatabase
out_event_lyr = arcpy.MakeXYEventLayer_management(input_rows, x_coords, y_coords, out_event_lyr, sr)
crash_fc = arcpy.CopyFeatures_management(out_event_lyr, os.path.join("%scratchFolder%\Geodatabase", gdb_name, out_event_fc))
crash_fc_lyr = arcpy.MakeFeatureLayer_management(crash_fc, "fc_lyr")
out_event_lyr_join = arcpy.AddJoin_management(crash_fc_lyr, "REPORT_NUMBER", event_rows, "REPORT_NUMBER")

arcpy.CopyFeatures_management(out_event_lyr_join, os.path.join("%scratchFolder%\Geodatabase", gdb_name, out_event_fc1))

My ArcGIS and Python skills are pretty rudimentary so I'm struggling trying to figure out what the issue is. I've been at it for almost 2 weeks! Doesn't seem like an unreasonable task I'm trying to accomplish but it has me stumped. What am I missing?

0 Kudos
2 Replies
by Anonymous User
Not applicable

ERROR 000210: Cannot create output -

Instead of the %scratchfolder%, try outputting it to an existing folder and make sure that you (or the c# application) can create the output there. If that works, you can start looking at alternatives or look into getting the %scratchfolder% to work.

0 Kudos
MarniFowler
Emerging Contributor

Thanks. I've gotten pulled off onto another task but will give this a try once that is complete.  It doesn't make sense because this is the exact same script we've been using for a good while. The only difference is we're trying to do the join to get more attributes.

0 Kudos