3

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.

5

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 
  • I will say though that the "GetOutput(0)" part need to have a lower case "g" to work i.e. "getOutput(0)". – Catchment_Jack Mar 28 '14 at 14:27
  • 1
    you're right, I've edited my answer – radouxju Mar 28 '14 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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