parsonz

Adding multiple rasters together using python

Discussion created by parsonz on Jul 18, 2012
Latest reply on Sep 26, 2012 by aorr
I have a number of raster datasets in a folder that I want to sum/add together.
I'm having trouble doing this - I've created a raster list but the output doesn't seem to be adding them together.

Can someone help please.

import arcpy, os
from arcpy import env

from arcpy.sa import *

arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True

env.workspace = r"C:\Users\Documents\GIS\Site Selection Example\Output Datasets\Cons_Raster"

rasterList  = arcpy.ListRasters("*")

for raster in rasterList:
    print raster
    # Execute CellStatistics
    outCellStatistics = CellStatistics(raster, "SUM", "NODATA")

    # Save the output 
    outCellStatistics.save("C:/data/sumRast.tif")


thanks Claire

Outcomes