Monday 26 January 2015

Averaging large number of raster layers using ArcGIS for Desktop?


I have a large number of rasters (300+) I would like to average using Raster Calculator as is explained at Averaging set of rasters using Raster Calculator of ArcGIS Desktop? I know I can manually select each raster by double-clicking, hitting the '+' key, and then dividing by the total number of files.


Is there a less tedious way to get the average raster, without having to double-click and hit "+" hundreds of times? (or typing each raster's filename into the box, or something similarly tedious)




Answer



As @FelixIP said, use Cell Statistics. You'll need the Spatial Analyst license, however.


enter image description here


Alternatively, if you don't have access to Spatial Analyst, and you're familiar with python, you could use arcpy. What I would do is:



  1. Loop through each raster and convert them to numpy arrays using RasterToNumpyArray.

  2. As you're looping through the rasters, store each numpy array into another numpy array (an array of arrays).

  3. Calculate the mean of that array.

  4. Convert that back to a raster using NumpyArrayToRaster.



I haven't tried this, but I'm pretty sure it should work.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...