<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding an Average Rainfall Data in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334715#M26152</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your help. It still produces the same results. I am just wondering why you put&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;inRaster = [] &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Isn't it the same as &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rasterFiles = arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have modified the code a bit and it takes the averages of all of the files. However, it does not exclude the file that has *.14. I changed these line&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; rasterFiles.append(filename) instead of inRasters&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;outRaster = CellStatistics(rasterFiles, "MEAN", "DATA") instead of inRasters&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the modified code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Input data source
arcpy.env.workspace = "S:/Work/Risa/Trial_Error/input"&amp;nbsp; # don't use spaces or special characters in path names
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/Work/Risa/Trial_Error/output/"

# Loop through a list of files in the workspace
rasterFiles = arcpy.ListRasters()

# The loop does nothing else but build the list
inRaster = []&amp;nbsp; # you need to do this outside of the loop
for filename in rasterFiles: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename.endswith("*.14.tif"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterFiles.append(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Now we have a list of the files we want to average, but you only need to calculate the average once, 
# which means this part should not be in the loop, so we remove indentation
outRaster = CellStatistics(rasterFiles, "MEAN", "DATA")
&amp;nbsp;&amp;nbsp; 
# Save the output 
outRaster.save("S:/Work/Risa/Trial_Error/output/AvgPrecip18.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Average Calculated!!!"

#takes the average and including the file that ends with *.14

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:51:37 GMT</pubDate>
    <dc:creator>RPatarasuk</dc:creator>
    <dc:date>2021-12-11T15:51:37Z</dc:date>
    <item>
      <title>Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334711#M26148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have about 350 files of PRISM rainfall data to process. I have e.g. precip from 1970 - 2010. and each year has 13 files. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.01.tif &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.02.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.03.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.04.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.05.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.06.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.07.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.08.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.09.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.10.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.11.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.12.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_1970.14.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_2010.11.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_2010.12.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ppt_2010.14.tif&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I try to write a python code to calculate a long term average. Here is the code that I have so far. I have only tried to play around with 5-10 files and the program only returns values for the last file (i.e. it doesn't add up the values of previous file and find the average). Also, I would like to exclude "*.14" from the calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Check out the ArcGIS Spatial Analyst extension license&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CheckOutExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Input data source&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "S:/Work/Risa/Trial &amp;amp; Error/input"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set output folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OutputFolder = "S:/Work/Risa/Trial &amp;amp; Error/output/"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Loop through a list of files in the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rasterFiles = arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for filename in rasterFiles:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRaster = arcpy.env.workspace + "/" + filename&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = OutputFolder + "/" + "AvgPrecip.tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #***need to process from all of the files except the ones that have "*.14" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Cell Statistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.CellStatistics_sa(inRaster, outRaster, "MEAN", "DATA")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "***DONE!!!"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be very appreciated. Thank you very much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Risa&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 18:46:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334711#M26148</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2012-05-02T18:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334712#M26149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First, please use CODE tags when you post actual Python code: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second, the "14" file that you want to exclude is actually the annual average. No need to include the other 12 files for each year.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Third, in answer to your question you could do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;inList = []
for filename in rasterFiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename.endswith('14'):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inList.append(filename)
arcpy.sa.CellStatistics(inList, outRaster, "MEAN", "DATA")&amp;nbsp; # this line was incorrect in your example&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334712#M26149</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-11T15:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334713#M26150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear philmorefield,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very&amp;nbsp; much for your help. I am very new to python and how to post the questions on the Forum. I tried to incorporated what you suggested but still has no luck. It doesn't append *.14 and it also calculates only the last file processed. Here is the code that I modified.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Input data source
arcpy.env.workspace = "S:/Work/Risa/Trial &amp;amp; Error/input"
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/Work/Risa/Trial &amp;amp; Error/output/"

# Loop through a list of files in the workspace
rasterFiles = arcpy.ListRasters()

# Local variables:
for filename in rasterFiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; inRaster = arcpy.env.workspace + "/" + filename
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename.endswith("*.14.tif"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRaster.append(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Cell Statistics
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = CellStatistics(inRaster, "MEAN", "DATA")
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Save the output 
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save("S:/Work/Risa/Trial &amp;amp; Error/output/AvgPrecip01.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Average Calculated!!!"
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334713#M26150</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2021-12-11T15:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334714#M26151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are a couple of problems that need to be addressed. I put in some comments to help explain. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Input data source
arcpy.env.workspace = "S:/Work/Risa/Trial_and_Error/input"&amp;nbsp; # don't use spaces or special characters in path names
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/Work/Risa/Trial_and_Error/output/"

# Loop through a list of files in the workspace
rasterFiles = arcpy.ListRasters()

# The loop does nothing else but build the list
inRasters = []&amp;nbsp; # you need to do this outside of the loop
for filename in rasterFiles: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename.endswith("14.tif"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRasters.append(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Now we have a list of the files we want to average, but you only need to calculate the average once, 
# which means this part should not be in the loop, so we remove indentation
outRaster = CellStatistics(inRasters, "MEAN", "DATA")
&amp;nbsp;&amp;nbsp; 
# Save the output 
outRaster.save("S:/Work/Risa/Trial_and_Error/output/AvgPrecip01.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Average Calculated!!!"&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Looping through files one of the most useful and common tasks in GIS. Once you get this mastered you'll be set!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334714#M26151</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-11T15:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334715#M26152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your help. It still produces the same results. I am just wondering why you put&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;inRaster = [] &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Isn't it the same as &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rasterFiles = arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have modified the code a bit and it takes the averages of all of the files. However, it does not exclude the file that has *.14. I changed these line&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; rasterFiles.append(filename) instead of inRasters&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;outRaster = CellStatistics(rasterFiles, "MEAN", "DATA") instead of inRasters&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the modified code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Input data source
arcpy.env.workspace = "S:/Work/Risa/Trial_Error/input"&amp;nbsp; # don't use spaces or special characters in path names
arcpy.env.overwriteOutput = True

# Set output folder
OutputFolder = "S:/Work/Risa/Trial_Error/output/"

# Loop through a list of files in the workspace
rasterFiles = arcpy.ListRasters()

# The loop does nothing else but build the list
inRaster = []&amp;nbsp; # you need to do this outside of the loop
for filename in rasterFiles: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename.endswith("*.14.tif"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterFiles.append(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Now we have a list of the files we want to average, but you only need to calculate the average once, 
# which means this part should not be in the loop, so we remove indentation
outRaster = CellStatistics(rasterFiles, "MEAN", "DATA")
&amp;nbsp;&amp;nbsp; 
# Save the output 
outRaster.save("S:/Work/Risa/Trial_Error/output/AvgPrecip18.tif")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
print "Average Calculated!!!"

#takes the average and including the file that ends with *.14

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334715#M26152</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2021-12-11T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334716#M26153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jook, you need the second list (inRasters = []) so that you have an empty place to put the rasters ending in "14.tif". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"rasterFiles = arcpy.ListRasters()" lists all of the rasters, then put the "14.tif" files into "inRasters". Then, calculate the mean of all of the rasters in "inRasters".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way you have modified the code will produce the original list of all rasters, plus any file in "14.tif", so you'll have two copies of each "14.tif".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, just to be clear you are not excluding the files ending in "14.tif", you are &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;only &lt;/SPAN&gt;&lt;SPAN&gt;using them (ie. you are excluding anything &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;not &lt;/SPAN&gt;&lt;SPAN&gt;ending in (14.tif")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 15:49:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334716#M26153</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-05-07T15:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334717#M26154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear Darren,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your reply. Maybe I said something wrong at the beginning. I want to include the files that ends with *.01 to *.12 but exclude *.14.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 16:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334717#M26154</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2012-05-07T16:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334718#M26155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Dear Darren,&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your reply. Maybe I said something wrong at the beginning. I want to include the files that ends with *.01 to *.12 but exclude *.14.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do that if you want. But as I pointed out earlier, the data you are working with already include the annual averages: the files ending in "14". If you're just going to average all months together, you can make things simpler and faster by just using the "14" files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, this is the change you should make to average 12 files from each year:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
inRaster = []&amp;nbsp; # you need to do this outside of the loop
for filename in rasterFiles: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Processing: " + filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if filename[-6:] in [str(x).zfill(2) + '.tif' for x in xrange(1, 13)]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterFiles.append(filename)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334718#M26155</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-11T15:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334719#M26156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Or, just to be lazy:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if &lt;STRONG&gt;not&lt;/STRONG&gt; filename.endswith("*.14.tif"):
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334719#M26156</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T15:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334720#M26157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Or, just to be lazy:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if &lt;STRONG&gt;not&lt;/STRONG&gt; filename.endswith("*.14.tif"):
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Touché. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Though you could run into trouble if some other raster is laying around in there. And also, the &lt;/SPAN&gt;&lt;STRONG&gt;endswith&lt;/STRONG&gt;&lt;SPAN&gt; method doesn't use asterisks as wildcards. It will evaluate the string literally and look for asterisks in the file name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt;filename = 'ppt_1970.14.tif'
&amp;gt;&amp;gt;&amp;gt;filename.endswith('14.tif')
True
&amp;gt;&amp;gt;&amp;gt;filename.endswith('*.14.tif')
False&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334720#M26157</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2021-12-11T15:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334721#M26158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Haha, now that I look at it "*.14.tif" wouldn't work even if it used wildcards - there's an extra '.'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, touché.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 19:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334721#M26158</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-05-07T19:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding an Average Rainfall Data</title>
      <link>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334722#M26159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear philmorefield &amp;amp; dkwiens,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works now. Thank you very much for your help. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if not filename.endswith("14.tif") -- this one works&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if not filename.endswith("*.14.tif") -- this one, Phil is right, keeps looking for the "*" so the program keeps running non stop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 13:23:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/finding-an-average-rainfall-data/m-p/334722#M26159</guid>
      <dc:creator>RPatarasuk</dc:creator>
      <dc:date>2012-05-11T13:23:24Z</dc:date>
    </item>
  </channel>
</rss>

