slburns

cell stats for many folders

Discussion created by slburns on Jun 19, 2011
Latest reply on Jun 20, 2011 by slburns
I have a main folder with many folders and each folder contains many rasters. I would like to run cell stats in each folder and output the cell stats in each of the folders.
I can get cell stats to work on one folder if I point it in that direction but I am not sure how to make the code run through each folder with out me pointing it there.
I have had a go:
import arcpy
from arcpy import env
from arcpy.sa import *
import os

env.workspace = "D:\groupedFFDI_Rasters\Seasons"
MainFolder="D:\groupedFFDI_Rasters\Seasons"

folderList=os.listdir(MainFolder)
for foldernames in folderList:
    print foldernames
    
    rasterlist = []
    for rasters in arcpy.ListRasters():
        rasterlist.append()
        print rasters
        outcellstats1 = CellStatistics(rasterlist, "MEAN", "DATA")
        print rasters
    outcellstats1.save(os.path.join(MainFolder,foldernames, "MEANall.img"))

print "end of processing" 

Outcomes