I am trying to calculate mean of selected raster chosen from multiple raster. I have multiple raster file in different month folder, i am trying to select only two raster (e.g For JANUARY : 001_Max_Temper.tif, 001_Min_Temper.tif) from different month folder (JANUARY, FEBRUARY....DECEMBER) and calculate the mean of those selected raster and save it as on same month folder (e.g output name, JANUARY: 001_Mean_Temp).
I have written a code to do this task but i am getting error massage while i am running this code. Below i have attached my code.
import arcpy, os, calendar
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
arcpy.env.parallelProcessingFactor = "100%"
topWorkspace = r'D:\SWAT-WEATHER-DATA2'
arcpy.env.workspace = topWorkspace
months = {calendar.month_name[i].upper(): str(i).zfill(3) for i in range(1, 13)}
for folderPath in arcpy.ListWorkspaces():
baseName = os.path.basename(folderPath).upper()
if baseName in months:
monthNumber = months[baseName]
arcpy.env.workspace = folderPath
rasterList = arcpy.ListRasters('*Max_Temper.tif', '*Min_Temper.tif')
outCellStatistics = CellStatistics(rasterList, "MEAN", "NODATA")
outRasterName = outCellStatistics, "Mean_Temp_{}.tif".format(monthNumber)
outCellStatistics.save(outRasterName)
print 'done'