AnsweredAssumed Answered

Create raster list by reading .tif files in multiple folders

Question asked by dljayasekera on Sep 13, 2017
Latest reply on Sep 14, 2017 by dljayasekera



I need to read multiple folders and read the .tif files and hold it a rasterlist. I have mycode below but it holds only last year tif. files.


Can somebody help me to read all the .tif files and hold in the raster list. ?


Thanks in advance.


Please see my code below:


years = [1981,1982,1983]
for year in years:
lstFiles = []
arcpy.env.workspace = r'H:\PRISM_800m_weekly_sum' + "\\" + str(year)
lstFiles = arcpy.ListRasters("*","TIF")
for raster in lstFiles:

>>> lstFiles
[u'Week_1_Sum1983_10.tif', u'Week_1_Sum1983_11.tif', u'Week_1_Sum1983_9.tif', u'Week_2_Sum1983_10.tif', u'Week_2_Sum1983_11.tif', u'Week_2_Sum1983_9.tif', u'Week_3_Sum1983_10.tif', u'Week_3_Sum1983_11.tif', u'Week_3_Sum1983_9.tif', u'Week_4_Sum1983_10.tif', u'Week_4_Sum1983_11.tif', u'Week_4_Sum1983_9.tif', u'Week_5_Sum1983_10.tif', u'Week_5_Sum1983_11.tif', u'Week_5_Sum1983_9.tif']