<?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: Raster Calculator Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656179#M51081</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try removing the ' before and after RasterImage in the Temp4 = FocalStatistics()... line. It´s a variable, i think they way you´ve got it in&amp;nbsp; there it´s looking for a string&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Nov 2011 14:38:44 GMT</pubDate>
    <dc:creator>RaphaelR</dc:creator>
    <dc:date>2011-11-29T14:38:44Z</dc:date>
    <item>
      <title>Raster Calculator Python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656175#M51077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to implement a simple raster calculator within my python script as the following &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;arcpy.gp.RasterCalculator_sa("\"%Temp4%\"/2", Temp2)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I am receiving the following error in python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Warning (from warnings module):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SyntaxWarning: import * only allowed at module level&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "F:\test.py", line 75, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.RasterCalculator_sa("\"%Temp4%\"/2", Temp2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in &amp;lt;lambda&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return lambda *args: val(*gp_fixargs(args))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.TypeError'&amp;gt;: unsupported operand type(s) for /: 'str' and 'int'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (RasterCalculator)."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using arcpy.CheckOutExtension("spatial") so im not sure what the first point of the error is implying!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is really frustrating... any help would be appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bjebn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 11:11:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656175#M51077</guid>
      <dc:creator>JohanL</dc:creator>
      <dc:date>2011-11-28T11:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656176#M51078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;according to the help, the raster calculator is for use inside arcmap only, for calculations in python you should use mapalgebra:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 14:30:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656176#M51078</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2011-11-28T14:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656177#M51079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;according to the help, the raster calculator is for use inside arcmap only, for calculations in python you should use mapalgebra:&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah of course... i did the mistake of exporting the script from the modelbuilder and tried to modify it -&amp;nbsp; what a frustrating mistake!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 17:16:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656177#M51079</guid>
      <dc:creator>JohanL</dc:creator>
      <dc:date>2011-11-28T17:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656178#M51080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am still having problems with map algebra... its probably an obvious mistake but I cant identify it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a part of the code im having trouble with...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;import arcpy, os, sys, string&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy.sa import *&lt;BR /&gt;&lt;BR /&gt;arcpy.CheckOutExtension("spatial")&lt;BR /&gt;&lt;BR /&gt;arcpy.env.workspace = r'O:\DATA\test'&lt;BR /&gt;InputFolder = arcpy.env.workspace&lt;BR /&gt;&lt;BR /&gt;Temp4 = InputFolder + '\\' + temp4&lt;BR /&gt;&lt;BR /&gt;RasterList = arcpy.ListRasters()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for RasterImage in RasterList:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp4 = FocalStatistics('RasterImage', NbrRectangle (9, 9, 'CELL'), "RANGE", "DATA")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ('Focal Statistics')&lt;BR /&gt;.....&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I receive the following error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "O:\test.py", line 67, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp4 = FocalStatistics('RasterImage', NbrRectangle (9, 9, 'CELL'), "RANGE", "DATA")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 4796, in FocalStatistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ignore_nodata)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Utils.py", line 47, in swapper&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = wrapper(*args, **kwargs)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 4790, in wrapper&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ignore_nodata)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in &amp;lt;lambda&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return lambda *args: val(*gp_fixargs(args))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;ERROR 000865: Input raster: RasterImage does not exist.&lt;/STRONG&gt;&lt;SPAN&gt;Failed to execute (FocalStatistics)."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It does not seem to recognize my for in loop of the RasterImage - any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 13:55:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656178#M51080</guid>
      <dc:creator>JohanL</dc:creator>
      <dc:date>2011-11-29T13:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator Python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656179#M51081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try removing the ' before and after RasterImage in the Temp4 = FocalStatistics()... line. It´s a variable, i think they way you´ve got it in&amp;nbsp; there it´s looking for a string&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 14:38:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-python/m-p/656179#M51081</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2011-11-29T14:38:44Z</dc:date>
    </item>
  </channel>
</rss>

