2

enter image description here

I am writing a script to be included in a toolbox but every time I am getting an error when I try to include the parameter using GetParameterAsText().

import numpy
from arcpy import env
from arcpy.sa import *


input_raster= arcpy.GetParameterAsText(0)
inputFeature= arcpy.GetParameterAsText(1)
clipRaster = arcpy.GetParameterAsText(2)
floodedArea = arcpy.GetParameterAsText(3)
output_folder = arcpy.GetParameterAsText(4)

and the error I get is...

Traceback (most recent call last):
  File "C:\Python27\dealingwithraster.py", line 16, in <module>
    output_folder =arcpy.GetParameterAsText(4)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\__init__.py", line 655, in GetParameterAsText
    return gp.getParameterAsText(index)
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 226, in getParameterAsText
    self._gp.GetParameterAsText(*gp_fixargs(args, True)))
RuntimeError: Object: Error in getting parameter as text

Failed to execute (dealingWithRaster).

Help needed because I can't seem to figure out the problem.

  • 3
    You have 5 input parameters in the code but only 4 in the script parameters. They must match in number and order/index. – BERA Jul 3 '17 at 10:58
2

You have 5 input parameters in the code but only 4 in the script parameters. They must match in number and order/index.

You are missing floodedArea in the script parameters.

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.