There are 2000 rasters inside the FOLDER/WORKSPACE

If I am going to use cellstat alone, CellStat would produce mean of 2000 rasters inside the FOLDER(ALL RASTERS). I want to average only every 5 raster which would result to 400 rasters.

How do you do this in ArcGIS 10.1?

closed as unclear what you're asking by ahmadhanb, nmtoken, whyzar, xunilk, BERA Mar 19 '18 at 14:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • How are the rasters named? – Hornbydd Mar 19 '18 at 8:45
  • Inside the Folder? M1...M2000.tif – user2543 Mar 19 '18 at 8:55

What you ask would be very difficult to do in ModelBuilder, there are not the tools that can create groups of data in that manner. You are hitting the limitations of ModelBuilder. This can however be done with a few lines of python as shown below.

import arcpy
folder = r"c:\temp"
outfolder = r"C:\tempout"
aL = []
for i in range(1,21): # for 1 to 20
    # create full name and append to list
    fullpath = folder + "\\M" + str(i) + ".tif"

    # When list hits contents of 5 do the analysis and then reset list
    if len(aL) == 5:
        print aL
        outCellStats = arcpy.sa.CellStatistics(aL,"MEAN")
        outpath = outfolder + "\\Mean_" + str(i) + ".tif"
        aL = [] # Reset list
  • What does it mean by range (1,21):? – user2543 Mar 19 '18 at 11:43
  • # for 1 to 20... I obvious don't have your data so to test the code I'm using less – Hornbydd Mar 19 '18 at 14:34
  • Thank you very much. I will test it today. Many people ask the same question so we thank you for your time helping us. – user2543 Mar 20 '18 at 0:31
  • I confirm that this code solved my problem. Just small detail though, in outpath = outfolder + "\\Mean_" + str(i) + ".tif", the file saves as and starts at Mean_3.tif? – user2543 Mar 20 '18 at 1:15
  • The output name is built from the current 'i' value which is always the end group value so in my example code the files would be named as: Mean_5.tif, Mean_10.tif, Mean_15.tif, Mean_20.tif. Thus Mean_15.tif would be the mean of the inputs: m11, m12, m13, m14, m15. You can save the output what ever you like, this was just a convenient method. – Hornbydd Mar 20 '18 at 9:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.