AnsweredAssumed Answered

CELL STATISTICS with LIST RASTERS

Question asked by tonalca6864 on Apr 23, 2018
Latest reply on Apr 23, 2018 by tonalca6864

Hi,

 

I'm trying to run Mean annual cell statistics for groups of monthly rasters.

 

The output I'm getting is the same as the last raster in the list ("camp_t_srf_sep" in this example) so i assume the script is not actually iterating through all rasters.

 

Any help will be greatly appreciate it.

 

# Example of list of rasters:
# camp_t_srf_apr
# camp_t_srf_aug
# camp_t_srf_dec
# camp_t_srf_feb
# camp_t_srf_jan
# camp_t_srf_jul
# camp_t_srf_jun
# camp_t_srf_mar
# camp_t_srf_may
# camp_t_srf_nov
# camp_t_srf_oct
# camp_t_srf_sep

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.overwriteOutput = True
env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)

env.workspace = arcpy.GetParameterAsText(0)
StageAge = arcpy.GetParameterAsText(1)


rasterlist = arcpy.ListRasters(StageAge + "_*")
for raster in rasterlist:
    output_mean = CellStatistics(raster, "MEAN", "DATA")
    output_mean.save(env.workspace + "\\" + raster[:11] + "ann")

Outcomes