maeven

Multiple rasters added together using python

Discussion created by maeven on Apr 8, 2011
Latest reply on Jul 25, 2011 by reuter
Hi,
I am working on adding several rasters together then dividing them by the number of rasters added (to find the average)

Is it possible to call the raster calculator in a stand alone script? Is it even possible to do this outside of ArcMap (works fine in a model calling the raster, but the snippet of python code doesn't work when placed into a script that is run from IDLE or PythonWIN), or do I have to add two together at a time using Plus repeatedly.

I keep getting this error:

return _wrapLocalFunctionRaster(u"Plus_sa", ["Plus", in_raster_or_constant1, in_raster_or_constant2])
RuntimeError: ERROR 000824: The tool is not licensed.

I am using ArcGIS 10 and python 2.6.

Below is my code

import os, sys, arcpy
from arcpy import env as e
from arcpy.sa import *

a1 = Raster(r"D:\raster1.tif")
a2 = Raster(r"D:\raster2.tif")
a3 = Raster(r"D:\raster3.tif")
a4 = Raster(r"D:\raster4.tif")

outras = (a1+a2+a3+a4)/4
outras.save(r"D:\")

Am I missing an extension?

If I use:

outras = arcpy.RasterCalculator_sa(a1+a2+a3+a4)

I get the error:
AttributeError: 'module' object has no attribute 'RasterCalculator_sa'

Very frustrating.
Thanks in advance for any suggestions

Mac

Outcomes