I have a script tool that is creating a least cost path for sets of points using a Cursor. When applied, the script runs great, except every so often the tool is stopped because there is an error in the Cost Path tool. If I close out of the tool and run the last few steps manually on the points everything works fine and I can start the tool on the next row.
Here is the cursor in the script:

rows = arcpy.SearchCursor(setExtract)
for row in rows:
    if row.setX == row.upX and row.setY == row.upY:
        arcpy.AddMessage("Points for trawl " + str(uniqueID) + " have identical coordinates, the trawl cannot be drawn.")
        avgDepth = row.avg_depth
        uniqueID = row.uniqueID
        arcpy.MakeFeatureLayer_management(setExtract, "setpoint", "uniqueID = " + str(uniqueID))
        arcpy.MakeFeatureLayer_management(upExtract, "uppoint", "uniqueID = " + str(uniqueID))
        outRas = Abs(Raster(clipBathy) - avgDepth)
        outRas.save(tempRasters + "\\cost" + str(uniqueID) + ".img")
        costRas = tempRasters + "\\cost" + str(uniqueID) + ".img"
        outCostDistance = CostDistance("uppoint", outRas, 500, tempRasters + "\\backlink" + str(uniqueID) + ".img")
        outCostDistance.save(tempRasters + "\\dist" + str(uniqueID) + ".img")
        distRas = tempRasters + "\\dist" + str(uniqueID) + ".img"
        backlinkRas = tempRasters + "\\backlink" + str(uniqueID) + ".img"
        outCostPath = CostPath("setpoint", distRas, backlinkRas)
        outCostPath.save(tempRasters + "\\path" + str(uniqueID) + ".img")
        pathRas = tempRasters + "\\path" + str(uniqueID) + ".img"

And here is the error:

Traceback (most recent call last):
  File "S:\Scripts\June6.py", line 138, in <module>
    outCostPath = CostPath("setpoint", distRas, backlinkRas)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 688, in CostPath
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 681, in wrapper
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 484, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
The table was not found. [CostPat_shp1]
The table was not found. [fras_bnd_CostPat_shp1]
The operation was attempted on an empty geometry.
ERROR 010029: Unable to create the raster C:\Users\amts\Documents\ArcGIS\Default.gdb\CostPat_shp1.
ERROR 010067: Error in executing grid expression.
Failed to execute (CostPath).

Both the backlink and cost distance rasters are saved and can be drawn in the map, so there doesn't appear to be anything wrong with them. Is this just 'one of those things' that happens in ArcGIS?

  • Change current and scratch directory, from environmental settings, to an intermediate folder instead of *.gdb for your session. Maybe it'll help.
    – Ibe
    Commented Jun 14, 2013 at 16:39
  • Hm, I changed them to a folder and now get the same text all through error 999999 and then this: ("esriDataSourcesRaster.GdalRasterDataset") Failed to open raster dataset ERROR 010414: Error in creating a Raster from a geodataset. This happened on the first iteration of the tool.
    – AlmaThom
    Commented Jun 17, 2013 at 22:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.