i'm trying to export a raster with its stretched values (0-255) and i can't figure out how to do it via the model builder.
normally this can be achieved by
right clicking the raster in the Table Of Contents
Data > Export Data...
Tick the "Use Renderer" box
how would i achieve this using the model builder?
The method you use from the GUI is not exposed in modelbuilder. You would have to calculate a new raster with the stretch.
Below are some notes I had written to myself:
You have a raster and you want to stretch the values into a different range. For example you have an elevation grid which ranges from 1 to 1000 but you want to stretch this into a grid ranging from 1 to 10. This is different to using the standard Reclassify tool as this would lump them into classes.
In a nutshell you convert you existing raster values to a proportion between 0 and 1 then alter the proportion value by a scalar.
In the example above we type the following into a raster calculator (remember to substitute the words with values):
(([EleGrid] - eleMin) / eleRange) * newRange ) + newMin
[EleGrid] = is the grid name, in this example assumed to be an elevation grid
eleMin = is the minimum value in your original grid, in this example 1
eleRange = is the range of values in your original grid, in this example 1000 - 1 = 999
newRange = is the range in your desired stretch, in this example 10 - 1 = 9
newMin = is the minimum value in your desired stretch value, in this example 1
so what you actually type into a raster calculator is:
(([EleGrid] - 1) / 999) * 9 ) + 1
If you would execute this in the Python window, you could use the raster properties min and max of the raster like this:
result = arcpy.sa.Int((arcpy.Raster('DTM_50cm') - arcpy.Raster('DTM_50cm').minimum) / (arcpy.Raster('DTM_50cm').maximum - arcpy.Raster('DTM_50cm').minimum) * 255)
The result may differ from the original stretch result, since stretching normally cuts of a percentage from start and end to optimize the stretch range.