1

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.

  • 1
    Looks like there may be an issue with a filepath to one of the arguments. What values are you entering for your parameters? – papadoo Jul 28 '14 at 16:44
  • All of the inputs are rasters in a float format. The cell size is an integer input (in this case I was inputting a cell size of 5). The outputs I set as two strings, one for the workspace and one for the raster output name. – Catchment_Jack Jul 28 '14 at 19:12
  • 1
    Can you add a screenshot of your script properties parameters? – papadoo Jul 28 '14 at 20:18
  • 2
    Your error message says dataset 5 is missing, do you have a dataset called 5? This is not a valid grid raster name. – Hornbydd Jul 28 '14 at 21:20
  • Hey, it looks to me like the parameter 4 and 5 is are output not an input. Try switching the parameters on the script tool from input to output for these two parameters. – Michael Stimson Jul 28 '14 at 22:10
2

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.

0

I figured out the issue.

The second parameter 'cellsize' needed to be called with the "arcpy.GetParameter" tool rather than the "arcpy.GetParameterAsText" tool as it is a numerical value rather than a string. It seems so obvious now!

I have amended my question with the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.