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)
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.