Python code for selecting and averaging raster layers within subfolders

Discussion created by deemcelligott on Aug 9, 2012
Latest reply on Aug 9, 2012 by temge-esristaff
Hi there,

Basically I have a folder with ten subfolders (one for each year of data...1992-2012), within each of these subfolders are 52 satellite images, one for each week of the corresponding year. I want to convert the weekly data into monthly data, thereby resulting in a single output for each month and twelve for each year. So I want to run a script that picks every four images consecutively, i.e tell it: the first four images = Jan, second four = Feb ............and so on, and get the average of these four images.

I can get the average by running the tool 'Cell Statistic' in Model builder and use 'Calculate Value' to allow me to enter the Python script to tell 'Cell Statistic' which four images to average.

I'm afraid my Python scripting capabilities are rather limited. Does anyone know a Python code to enable me to do this?

I hope it makes sense!