Failed to open raster dataset

5165
3
01-26-2011 02:34 PM
JamesHook
New Contributor II
I wrote a python script that works beautifully, but when I try to run it as a script from ArcToolbox, it crashes when I try to do an Extract By Mask.  Here is the problem script:

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial") # Loads Spatial Analyst extension

dem = arcpy.GetParameterAsText(0)
arcpy.AddMessage(dem) # "C:/Elevation Files/dem_file"
bsnDEM = ExtractByMask(dem, basinFile)

Which raises the error:
<class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function.
Failed to open raster dataset
Failed to execute (ExtractByMask).


Why would this work outside of a tool but not when executed from the toolbox?
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
arcpy.AddMessage(dem)

what did it print? or did it?
0 Kudos
JamesHook
New Contributor II
It printed the correct path for the DEM as indicated in the commented part of the line.  If I change the input to a path that doesn't exist, it returns an error saying the layer doesn't exist, instead of the error saying it simply failed to load.
0 Kudos
JamieKass
Occasional Contributor
Has this issue been addressed? I have this problem all the time, and I find that for the most part, even though I receive an error, the raster is created nonetheless.
0 Kudos