<?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: Moving average in Model Builder in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/moving-average-in-model-builder/m-p/875450#M3517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you clarify&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do you want a single number for the moving window&lt;/LI&gt;&lt;LI&gt;Do you want an output raster for the moving window that would have an average per sequence&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This demo will exemplify the difference...(I have used numpy arrays to demonstrate)&lt;/P&gt;&lt;P&gt;Of course this can be greatly simplified is you use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/rastertonumpyarray-function.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/rastertonumpyarray-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;RasterToNumPyArray—Help | ArcGIS for Desktop&lt;/A&gt; to get the rasters into array format then use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/numpyarraytoraster-function.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/numpyarraytoraster-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;NumPyArrayToRaster—Help | ArcGIS for Desktop&lt;/A&gt; to get any needed back to raster format.&amp;nbsp; Mean operation can be put through a 'moving' sequence so that you don't have to manually perform any of the steps.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the result you need is important&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import numpy as np
r1 = np.arange(9).reshape(3,3)
r2 = np.arange(1,10).reshape(3,3)
r3 = np.arange(2,11).reshape(3,3)
print("\ninputs\n{}\n{}\n{}".format(r1,r2,r3))
print("\nmoving average 1 {}".format(np.mean((r1,r2,r3))))
print("\nmoving,focal average\n{}".format(np.mean((r1,r2,r3),axis=0)))
​
Which yields
inputs
[[0 1 2]
[3 4 5]
[6 7 8]]

[[1 2 3]
[4 5 6]
[7 8 9]]

[[ 2&amp;nbsp; 3&amp;nbsp; 4]
[ 5&amp;nbsp; 6&amp;nbsp; 7]
[ 8&amp;nbsp; 9 10]]

moving average 1 5.0

moving,focal average
[[ 1.&amp;nbsp; 2.&amp;nbsp; 3.]
[ 4.&amp;nbsp; 5.&amp;nbsp; 6.]
[ 7.&amp;nbsp; 8.&amp;nbsp; 9.]]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:58:57 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-12T10:58:57Z</dc:date>
    <item>
      <title>Moving average in Model Builder</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/moving-average-in-model-builder/m-p/875449#M3516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear GIS experts,&lt;/P&gt;&lt;P&gt;I have many rasters of the same bounding box and I would like to calculate moving average from them. For example from 100 rasters I need to calculate average from rasters 1;2;3, then from 2;3;4 and so on till 98;99;100. Do you know, if it is possible to do it using Model Builder?&lt;/P&gt;&lt;P&gt;Many thanks !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 07:36:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/moving-average-in-model-builder/m-p/875449#M3516</guid>
      <dc:creator>JanRussnak</dc:creator>
      <dc:date>2015-07-02T07:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Moving average in Model Builder</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/moving-average-in-model-builder/m-p/875450#M3517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you clarify&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do you want a single number for the moving window&lt;/LI&gt;&lt;LI&gt;Do you want an output raster for the moving window that would have an average per sequence&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This demo will exemplify the difference...(I have used numpy arrays to demonstrate)&lt;/P&gt;&lt;P&gt;Of course this can be greatly simplified is you use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/rastertonumpyarray-function.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/rastertonumpyarray-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;RasterToNumPyArray—Help | ArcGIS for Desktop&lt;/A&gt; to get the rasters into array format then use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/numpyarraytoraster-function.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/numpyarraytoraster-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;NumPyArrayToRaster—Help | ArcGIS for Desktop&lt;/A&gt; to get any needed back to raster format.&amp;nbsp; Mean operation can be put through a 'moving' sequence so that you don't have to manually perform any of the steps.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the result you need is important&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import numpy as np
r1 = np.arange(9).reshape(3,3)
r2 = np.arange(1,10).reshape(3,3)
r3 = np.arange(2,11).reshape(3,3)
print("\ninputs\n{}\n{}\n{}".format(r1,r2,r3))
print("\nmoving average 1 {}".format(np.mean((r1,r2,r3))))
print("\nmoving,focal average\n{}".format(np.mean((r1,r2,r3),axis=0)))
​
Which yields
inputs
[[0 1 2]
[3 4 5]
[6 7 8]]

[[1 2 3]
[4 5 6]
[7 8 9]]

[[ 2&amp;nbsp; 3&amp;nbsp; 4]
[ 5&amp;nbsp; 6&amp;nbsp; 7]
[ 8&amp;nbsp; 9 10]]

moving average 1 5.0

moving,focal average
[[ 1.&amp;nbsp; 2.&amp;nbsp; 3.]
[ 4.&amp;nbsp; 5.&amp;nbsp; 6.]
[ 7.&amp;nbsp; 8.&amp;nbsp; 9.]]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:58:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/moving-average-in-model-builder/m-p/875450#M3517</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T10:58:57Z</dc:date>
    </item>
  </channel>
</rss>

