[GIS] Error 000732 – input raster does not exist when implementing script tool arcpy

arcgis-10.0arcpyerror-000732

I am trying to implement a script tool in ArcGIS 10 that completes a few equations with raster datasets.

I seem to be getting the same error no matter what I try:

<type 'exceptions.RuntimeError'>: ERROR 000732: Input Raster: Dataset 5 does not exist or is not supported
Failed to execute (TWI).

TWI being the name of the script tool.

My code is below:

import arcpy
from arcpy import env
import os
from arcpy.sa import *
arcpy.CheckOutExtension("spatial")

DEM = arcpy.GetParameterAsText(0)
cellsize = arcpy.GetParameterAsText(1)
FlowAcc = arcpy.GetParameterAsText(2)
K_Sat = arcpy.GetParameterAsText(3)
OutRaster = arcpy.GetParameterAsText(4)
OutSpace = arcpy.GetParameterAsText(5)

slope = (Slope(Raster(DEM)) * 1.570796 ) / 90
tan_slp = Con(slope > 0, Tan(slope), 0.001)
FlowAcc_scaled = (Raster(FlowAcc) + 1 ) * cellsize
TWI = Ln(FlowAcc_scaled / (Raster(K_Sat) * tan_slp))

arcpy.env.workspace = OutSpace

TWI.save(OutRaster)

I've got a feeling that the error is something to do with setting up the parameters correctly. It's something that I seem to be struggling to get my head around but as I understand it "DEM", "FlowAcc" and "K_Sat" are raster layers, "cellsize" is a long integer (also tried double), "OutSpace" is a workspace and "OutRaster" is a string.

The error seems to be with the way is is saving/naming the raster.

EDIT:
Please see a screenshot of the parameter setup below (note I have tried the output workspace and output raster as both inputs and outputs and I get the same error)

enter image description here

EDIT 2 – Answer

Ok the issue was that the second parameter 'cellsize' needs to be called with the 'arcpy.GetParameter' function rather than the 'arcpy.GetParameterAsText' function as it is an input value rather than a string.

Best Answer

Here is a basic explanation on this error - This occurs even though the data clearly does exist on disk.

Cause Most often this is due to the input data path being entered incorrectly, as in the following situations:

• Misspelled folder names

• Using backslashes instead of forward slashes

• Having spaces in the path names

If the data clearly does exist, then the problem may be one of two known limits. See the Solution section for details.

Solution or Workaround Check the data path used, correct it as required and run the tool again.

If the data does exist, one of the following may be occurring:

If the input is a geodatabase feature class or table, an invalid subtype may exist on the dataset. To fix it, go to the feature class properties, then click the Subtypes tab and re-enter the default subtype code. If the default is zero (0), then click the cell with 0 and re-enter that same value. Apply the change by clicking the OK button. The dataset should now be usable. If the tool is being run on UNIX or Linux and the input is a text file that is being used as input to a tool with an input table parameter, such as CopyRows or MakeXYEventLayer, this is a known limit. On the Windows operating system the text file is represented as a table using a module,which is not available on UNIX or Linux. Change the data frame coordinate system to match the data being exported. If applicable, turn off live database connections at the layer level, and not just the subgroup. Turn off background processing. In ArcCatalog: Geoprocessing > Geoprocessing option > Clear Enable under Background Processing.