Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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) + "\\cost" + str(uniqueID) + ".img")
        costRas = tempRasters + "\\cost" + str(uniqueID) + ".img"
        outCostDistance = CostDistance("uppoint", outRas, 500, tempRasters + "\\backlink" + str(uniqueID) + ".img") + "\\dist" + str(uniqueID) + ".img")
        distRas = tempRasters + "\\dist" + str(uniqueID) + ".img"
        backlinkRas = tempRasters + "\\backlink" + str(uniqueID) + ".img"
        outCostPath = CostPath("setpoint", distRas, backlinkRas) + "\\path" + str(uniqueID) + ".img")
        pathRas = tempRasters + "\\path" + str(uniqueID) + ".img"

And here is the error:

Traceback (most recent call last):
  File "S:\Scripts\", line 138, in <module>
    outCostPath = CostPath("setpoint", distRas, backlinkRas)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\", line 688, in CostPath
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\", line 681, in wrapper
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\", 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?

share|improve this question
Change current and scratch directory, from environmental settings, to an intermediate folder instead of *.gdb for your session. Maybe it'll help. – Ibe Jun 14 '13 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 Jun 17 '13 at 22:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.