Monthly Averages for 30 yr dataset

451
2
Jump to solution
06-19-2014 07:18 AM
SarahNiemczura
New Contributor III
Morning, I've been digging through the forum for a few days to find a script that could help me. I've currently found:

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") 


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
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus
shouldn't the last four lines be indented as well?

View solution in original post

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
shouldn't the last four lines be indented as well?
0 Kudos
SarahNiemczura
New Contributor III
shouldn't the last four lines be indented as well?


Go figure that it was something that simple.

Currently running it now and it seems to be working.

Thanks!
0 Kudos