5

I have been trying to 'range standardise' or normalise my raster values from 0-100 and I know how to do this mathematically:

("raster"-min("raster"))/(max("raster")-min("raster"))*100

and I have input this equation into the raster calculator using both the min() and max() and the .minimum and .maximum syntax.

Why are these not working for me? ArcGIS 10.3.1

  • This may have been marked as duplicate but the 'calculate statistics' comment was what my approach was missing and this is not included in the 'duplicate' question. – tda Nov 9 '16 at 15:02
9

Raster objects have minimum and maximum (as well as mean and standardDeviation) properties that can be accessed in the raster calculator.

("raster" - "raster".minimum) / ("raster".maximum - "raster".minimum) * 100

This will work as long as you have already calculated statistics for the raster, otherwise it will fail as "raster".minimum will return None.

enter image description here

Messages
Executing: RasterCalculator "("raster" - "raster".minimum) / ("raster".maximum - "raster".minimum) * 100" c:\Temp\Default.gdb\rastercalc
Start Time: Tue May 10 09:46:45 2016
(Raster(r"raster") - Raster(r"raster").minimum) / (Raster(r"raster").maximum - Raster(r"raster").minimum) * 100
Succeeded at Tue May 10 09:46:48 2016 (Elapsed Time: 3.17 seconds)
  • This is cool, what version did they add the "." properties call? – Jeffrey Evans May 13 '16 at 16:36
  • Hi Luke, do you calculate statistics when you go into the properties of each raster layer? Or am I missing something? Thanks for your comment - this was the kind of thing I was after! – tda May 14 '16 at 21:54
  • @TaylorDay use the calculate statistics tool I linked to in my answer – user2856 May 14 '16 at 22:01
  • @JeffreyEvans, I assume when the Arcpy.Raster object was added, probably 10.0, but I don't know for certain. – user2856 May 14 '16 at 22:06
3

The Rescale by function tool lets you rescale raster files, including performing basic normalization/standardization using a linear function.

The Calculate statistics lets you find the minimum and maximum inside the tool, and automatically populate the values.

enter image description here

2

There are no min or max functions that you can call directly in the raster calculator. You have to provide the raster statistics (min and max). You can get the global raster statistics by right clicking on the raster in the TOC and selecting properties. In the resulting window select the "source" tab and scroll down in properties. Use these minimum and maximum values.

I should note that you only need this equation if you have a raster that has negative values. Otherwise, all you need to do is divide the raster by its maximum value (which will scale to 0-1) and then multiply by 100 to scale to 0-100. This is commonly referred to as row standardization. Also, standardizing and normalizing are different things entirely. There is a brief discussion in this thread on standardization.

  • Not quite true Jeffrey. The rasters have minimum and maximum (as well as mean and standardDeviation) properties that can be accessed in the raster calculator. – user2856 May 9 '16 at 23:57
  • @Luke, I was referring to the code the OP posted, there are still no actual commands called min or max. – Jeffrey Evans May 13 '16 at 16:34
1

If you're working in python, you should operate on a numpy array:

import numpy
import arcpy

# load data, convert to array
orig_raster = arcpy.Raster('path/to/project/dem.tif'
array = arcpy.RasterToNumPyArray(orig_raster)

# do your math
new_array = (array - array.min()) / (array.max() - array.min()) * 100

# back to a raster
new_raster = arcpy.NumPyArrayToRaster(
    in_array=new_array,
    lower_left_corner=orig_raster.extent.lowerLeft,
    x_cell_size=orig_raster.meanCellWidth,
    y_cell_size=orig_raster.meanCellHeight,
)

# and scene
new_raster.save('path/to/project/new_dem.tif')
0

If you are writing a python script try arcpy.GetRasterProperties_management http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//0017000000m7000000

In ModelBuilder you can get min and max using Zonal Statistics. You could also come up with a nested map algebra statement that includes zonal statistics, but it probably wouldn't be worth if you are only normalizing 1 or 2 rasters.

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