<?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: Multiple rasters added together using python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55322#M4347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Resolved. I ended up ditching the raster calcuator and used the weightedsum tool instead&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Apr 2011 18:36:33 GMT</pubDate>
    <dc:creator>Heatherna</dc:creator>
    <dc:date>2011-04-08T18:36:33Z</dc:date>
    <item>
      <title>Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55319#M4344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on adding several rasters together then dividing them by the number of rasters added (to find the average)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to call the raster calculator in a stand alone script? Is it even possible to do this outside of ArcMap (works fine in a model calling the raster, but the snippet of python code doesn't work when placed into a script that is run from IDLE or PythonWIN), or do I have to add two together at a time using Plus repeatedly. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I keep getting this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return _wrapLocalFunctionRaster(u"Plus_sa", ["Plus", in_raster_or_constant1, in_raster_or_constant2])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: ERROR 000824: The tool is not licensed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS 10 and python 2.6.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is my code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os, sys, arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env as e&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;a1 = Raster(r"D:\raster1.tif")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a2 = Raster(r"D:\raster2.tif")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a3 = Raster(r"D:\raster3.tif")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a4 = Raster(r"D:\raster4.tif")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;outras = (a1+a2+a3+a4)/4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outras.save(r"D:\")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I missing an extension?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;outras = arcpy.RasterCalculator_sa(a1+a2+a3+a4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'module' object has no attribute 'RasterCalculator_sa'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very frustrating.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for any suggestions&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mac&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 07:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55319#M4344</guid>
      <dc:creator>Heatherna</dc:creator>
      <dc:date>2011-04-08T07:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55320#M4345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;see the standalone script example in the help file, you need to checkout the extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 07:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55320#M4345</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-04-08T07:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55321#M4346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, I tried that and I still get an error as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; debugger.run(codeObject, __main__.__dict__, start_stepping=0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 655, in run&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec cmd in globals, locals&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "D:\average3.py", line 70, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outras = arcpy.RasterCalculator_sa(a1+a2+a3+a4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'module' object has no attribute 'RasterCalculator_sa'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any other thoughts? I keep poking at it but its still not working&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 11:42:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55321#M4346</guid>
      <dc:creator>Heatherna</dc:creator>
      <dc:date>2011-04-08T11:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55322#M4347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Resolved. I ended up ditching the raster calcuator and used the weightedsum tool instead&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 18:36:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55322#M4347</guid>
      <dc:creator>Heatherna</dc:creator>
      <dc:date>2011-04-08T18:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55323#M4348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;why not use the plus syntax&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outPlus = Plus(inRaster1, inRaster2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for further information&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 18:42:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55323#M4348</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-04-08T18:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55324#M4349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I haven't tested this out, but the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm"&gt;Raster Calculator help&lt;/A&gt;&lt;SPAN&gt; says the syntax is RasterCalculator(...) not RasterCalculator_sa (which is tricky - bad ESRI).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 18:44:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55324#M4349</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-04-08T18:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55325#M4350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;why not use the plus syntax&lt;BR /&gt;&lt;BR /&gt;from arcpy.sa import *&lt;BR /&gt;outPlus = Plus(inRaster1, inRaster2)&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z00000096000000.htm&lt;/A&gt; &lt;BR /&gt;for further information&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I needed to use more than two rasters, the plus tool only allows for two inputs.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2011 19:20:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55325#M4350</guid>
      <dc:creator>Heatherna</dc:creator>
      <dc:date>2011-04-11T19:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55326#M4351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;then cell statistics may be what you are looking for&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000007q000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000007q000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2011 21:51:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55326#M4351</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-04-11T21:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55327#M4352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please note:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The help for the RasterCalculater in 10.0 states: The Raster Calculator tool is intended for use in the ArcGIS Desktop application only as a GP tool dialog box or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Spatial Analyst module.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Raster Calculator is not supported in scripting because in ArcGIS 10 Map Algebra can be accessed directly when using the geoprocessing ArcPy site-package.&amp;nbsp; This seamless integration of Map Algebra into Python extends the capabilities of Map Algebra by taking advantage of Python and third party Python modules and libraries; making Map Algebra far more powerful than it has been in the past.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reference:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://blogs.esri.com/dev/blogs/geoprocessing/archive/2010/04/28/the-new-and-improved-raster-calculator-tool-for-arcgis-10.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://blogs.esri.com/dev/blogs/geoprocessing/archive/2010/04/28/the-new-and-improved-raster-calculator-tool-for-arcgis-10.aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The solution to your problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) You will need to checkout the Spatial Analyst License to use operators or any Spatial Aanlayst tools with rasters.&amp;nbsp; &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CheckOutExtension('Spatial')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To obtain your average use one of the following.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A) &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;outras = (a1+a2+a3+a4)/4
outras.save("averaster')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;B)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;outras = arpcy.sa.CellStatisitics([a1,a2,a3,a4], "MEAN")
outras.save("averaster")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55327#M4352</guid>
      <dc:creator>RyanDeBruyn</dc:creator>
      <dc:date>2021-12-10T22:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple rasters added together using python</title>
      <link>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55328#M4353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you checking out the spatial analyst extension ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running code below! &lt;/SPAN&gt;&lt;BR /&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;SPAN&gt;arcpy.env.scratchWorkspace = "yourscratch"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "yourworkspace"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CheckOutExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;final = (Raster('Raster_a_withpath' + Raster('Raster_b_with_Path' + ...) / 4 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;final.save(youroutrastername)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S.:keep in mind, there are strong differences between Single python and buildin python in AG10 syntax.. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S.: type dir(arcpy.sa)&amp;nbsp; helps to identify the avaiable commands&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S.P.S: help(Raster) helps to identify the syntax for a specific command&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS.PS: Don"t use the "FROM" keyword for example in Reclass Table as it is a Keyword in Python!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 10:34:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-rasters-added-together-using-python/m-p/55328#M4353</guid>
      <dc:creator>Hannes_I_Reuter</dc:creator>
      <dc:date>2011-07-25T10:34:36Z</dc:date>
    </item>
  </channel>
</rss>

