2

I am customizing the script tool behaviour of a custom script and would like to get the min-max values from a raster self.params[0] and populate the next two parameters, self.params[1] and self.params[2], with these values. Here is what I have so far but of course, it doesn't work.

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parmater
    has been changed."""

    if self.params[0].altered and self.params[0].value:
        paramInRaster = arcpy.Raster(self.params[0])
        minVal = paramInRaster.minimum
        maxVal = paramInRaster.maximum
        self.params[1].value = minVal
        self.params[2].value = maxVal
    return

1 Answer 1

3

In the following line, you are grabbing the parameter object instead of the value:

     paramInRaster = arcpy.Raster(self.params[0])

Try changing it to:

     paramInRaster = arcpy.Raster(self.params[0].value)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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