[GIS] Find maximum and minimum value in a list of rasters

arcgis-10.0arcgis-desktoparcpynormalizeraster

I trying to write a standardisation script that standardises each raster dataset in a list of rasters by the highest and lowest values found in the list of rasters.

The standardisation code is as follows:

for raster in rasters:
  output = (Raster(raster) - min_value) *100 / (max_value - min_value) + 0

Where the max_value and min_value are the maximum and minimum values in the raster list.

I initially though I would be able to use the GetRasterProperties_management function on the raster list but this doesn't work because the raster list is just a list!

The other idea I had was to loop through each raster in the list getting the max and min values and then outputting them as a table of values. Then finding the max and min value in each table to use in the standardisation equation. But I'm struggling to figure out how to output max and min values as a table.

So I would like help if anyone has got a better idea for the whole procedure or knows how to output max and min values from a looped GetRasterProperties_management into a table.

I'm using ArcGIS 10.

Best Answer

You could do a first loop for the min and max values using getRasterproperties. Example for the max value below (min can be done in the same loop).

max_value=0

for raster in rasters:
  max_val_tmp = int(arcpy.GetRasterProperties_management(raster, "MAX").getOutput(0))
  if max_val_tmp > max_value:
    max_value = max_val_tmp 
Related Question