Select to view content in your preferred language

Cell Statistics Bug

1420
1
04-20-2011 10:06 AM
MatthewNordhagen
Frequent Contributor
Hi All - I was wondering if somebody would be willing to provide some information on a problem I've been having lately with using Cell Statistics in Python?  Specifically,  I wanted to use Cell Stats to give me the Max cell value for each pixel in a list of 20 rasters.  Below is the code:

env.workspace = workspace
for rasters in arcpy.ListRasters():
    evi = arcpy.Raster(rasters)
CellStats = CellStatistics([evi], "MAXIMUM", "DATA")
CellStats.save(output + "MeanMax")


The result is a raster that has the SUM of all the pixels not the MAX.  When using the tool directly in ArcGIS Desktop 10 and I add all 20 of my rasters the output is correct.  Any thoughts on why the tool in python is adding all the cells together instead of providing me the max value?  Thanks much.
0 Kudos
1 Reply
MatthewNordhagen
Frequent Contributor
Just thought I would answer my own post by mentioning that it isn't a bug with Cell Stats but a problem with the person who wrote the above code 😉  For those interested here is the way it should be....

rasterlist = []
for rasters in arcpy.ListRasters():
    rasterlist.append(rasters)
    outcellstats = CellStatistics(rasterlist, "MAXIMUM", "DATA")
outcellstats.save(output + "maximum_2006")
0 Kudos