2

I'm building a model (ModelBuilder) at ArcMap 10.3.1. How can I get an output (can be a string) of the maximum and the minimum value of a raster to use it on raster calculator?

Actually I'm using the Get Raster Properties tool, and the result I'm putting on raster calculator like this:

-> Square("%raster%" - "%raster_max%"/"%raster_max%" - "%raster_min%")

My problem is that the Get Raster Properties does not export a string with the value. I would like to know if there is a tool or a way using ModelBuilder to extract to Max and Min value of a raster to directly apply on Raster Calculator.

edit: I tried to use Calculate Value tool, with the code:

import arcpy
#Get the geoprocessing result object
maxValueResult = arcpy.GetRasterProperties_management("c:.../..", "MAXIMUM")
#Get the MAX value from geoprocessing result object
maxValue = maxValueResult.getOutput(0)

But it keeps exporting the number only in the results, and it does not convert into a string to use on raster calculator.

1

Assuming the raster has already had statistics calculated, you can access the max and min values in the raster calculator directly using "your_raster".maximum and "your_raster".minimum syntax. See this answer for more details.

1

Below is a silly model that gets the MAXIMUM value of a raster and then adds it to itself then takes the square:

Using maximum value

There is no need to convert the output of the properties tool into a string.

  • Thank you very much for the answer. Already tried that: Square("%NDVI%" + float(%maxvalue%)) I think the problem is that the number have a negative or positive signal. Error: Square(Raster(r"C:\...") + float(0,586451292037964)) ERROR 000539: Error running expression: rcexec() Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 5, in rcexec TypeError: float() takes at most 1 argument (2 given) Failed to execute (Pv Calculator) – Apatons Jan 14 '17 at 16:56

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.