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.
Answer
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.
No comments:
Post a Comment