AnsweredAssumed Answered

Parse rasters by string in name

Question asked by DZelmanfahm@golder.com_GolderGlobalGIS on Aug 12, 2018
Latest reply on Aug 13, 2018 by xander_bakker

Hello! I have 750+ rasters with precipitation data. The folder contains a raster for each month for the years 1945-2009. I need to find the mean of each year in a new raster. However, I am getting caught up on how to parse all the rasters with the specific years in their name. I am only able to run the calcs on one  year at a time. The rasters are named like Oct2009.tif, Nov2009.tif, Nov2008.tif, etc. 

import arcpy
# Define input workspace and create list of rasters
arcpy.env.workspace = r'C:\Users\dzelmanfahm\Desktop\DEM_Trials'
rasters = arcpy.ListRasters("*2009*")
# Run cell statistics
calc =, statistics_type = "MEAN")'C:\Users\dzelmanfahm\Desktop\OUTPUT_DEM_TRIALS\Raster.tif')