Morning, I've been digging through the forum for a few days to find a script that could help me. I've currently found:
However when I run this, it will only iterate through the 12th month - it will not do the others. How can I make it so the code will iterate through December of all the years, then January, February, and so on?
Any thoughts would be helpful! Thanks!
SN
Code:
import arcpy
arcpy.CheckOutExtension("spatial")
arcpy.env.workspace = "F:\\ECV\\netCDFtoRaster"
arcpy.env.overwriteOutput = True
for year in range(1990,2010): # 1990 through 2010
for month in range(13): # 1 to 12
# wildcard - "ECV_SM_MERG_{1:02d}*.TIF" (format month 1 -> "01")
wild = "ECV_SM_MERG_{1:02d}*.TIF".format(year, month)
rasters = arcpy.ListRasters(wild) # list all rasters for a month
output = "F:\\ECV\\Month_"+str(month)+"_"+str(year)+".tif"
for raster in rasters:
# Process: Cell Statistics
print (rasters)
arcpy.gp.CellStatistics_sa(rasters, output, "MEAN", "DATA")
Any thoughts would be helpful! Thanks!
SN