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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 14, 2017 at 15:23

2 Answers 2

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.

answered Jan 14, 2017 at 21:24
0
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.

answered Jan 14, 2017 at 16:32
1
  • 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) Commented Jan 14, 2017 at 16:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.