<?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: error message at raster calculator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73809#M6043</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like there may be a bug with "MAXOF" &amp;amp; "MINOF" properties.&amp;nbsp; I tested this and always received a Runtime Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: No CellSize and Extent set&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you set the 'arcpy.env.cellSize' and 'arcpy.env.extent' to a raster, or to a constant (i.e. 10) the code should work.&amp;nbsp; You may want to report this issue to Tech Support.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2012 18:21:48 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2012-05-11T18:21:48Z</dc:date>
    <item>
      <title>error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73805#M6039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My Python code throws an error at the first raster calculator statement claiming that no cell size or extent are set.&amp;nbsp; I don't see&amp;nbsp; why this is necessary in this script but I put in some extent and cell size statements anyway.&amp;nbsp; That didn't help, the code still throws the same error at the first raster calculator statement.&amp;nbsp; Any help is welcomed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy, os, sys, traceback
&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy.sa import *
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("Spatial")
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; degreesSlope = Raster(r"C:\gtemp\FS_test\slope_degree")
&amp;nbsp;&amp;nbsp;&amp;nbsp; totalSoilThickness = Raster(r"C:\gtemp\FS_test\soildepth")
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilThickness = Raster(r"C:\gtemp\FS_test\dw")
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeRootStrength = Raster(r"C:\gtemp\FS_test\rootcohesion")
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeSurcharge = Raster(r"C:\gtemp\FS_test\surcharge")
&amp;nbsp;&amp;nbsp;&amp;nbsp; moistSoilUnitWeight = Raster(r"C:\gtemp\FS_test\moist_uw")
&amp;nbsp;&amp;nbsp;&amp;nbsp; numerator = "numerator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; denominator = "denominator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Constants...
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; soilCohesion = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; effectiveInternalAngleofFriction = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; drySoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; waterUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; rastercalc = r"C:\gtemp\FS_test\dwrastercalc"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.cellSize = "MAXOF"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.extent = "MAXOF"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.RasterCalculator_sa((treeRootStrength + soilCohesion + Square(Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness)+ (saturatedSoilUnitWeight-waterUnitWeight)*saturatedSoilThickness)*Tan(effectiveInternalAngleofFriction)), numerator)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.RasterCalculator_sa((Sin(degreesSlope)*Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness) + drySoilUnitWeight * saturatedSoilThickness), denominator)
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.RasterCalculator_sa(numerator/denominator, rastercalc )

&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Done!")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 
except arcpy.ExecuteError: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = arcpy.GetMessages(2) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 14:22:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73805#M6039</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2012-05-11T14:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73806#M6040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Gerry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Raster Calculator needs to be executed in Desktop or Model Builder.&amp;nbsp; See &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000z7000000.htm"&gt;here&lt;/A&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The Raster Calculator tool is intended&amp;nbsp; for use in the ArcGIS Desktop&amp;nbsp; application only as a GP tool dialog box&amp;nbsp; or in ModelBuilder. It is not&amp;nbsp;&amp;nbsp; intended for use in scripting and is not&amp;nbsp; available in the ArcPy&amp;nbsp; Spatial Analyst module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will want to use the Spatial Analyst 'Math' tools to perform your Raster calculations (i.e. &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000009p000000.htm"&gt;Times&lt;/A&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Plus/009z00000096000000/"&gt;Plus&lt;/A&gt;&lt;SPAN&gt;, etc).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 14:45:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73806#M6040</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-05-11T14:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73807#M6041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, I removed the raster calculator functions from the script.&amp;nbsp; According to the literature I can use raster calculator like expression (+,-,/...) as long as I cast the raster as 'rasters'.&amp;nbsp; I can get something like the below to work without error, but I cant get passed 'numerator' in the code below without getting the cell size and extent not set error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Raster("test1")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Raster(test2")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thesum = test1 + test2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy, os, sys, traceback
&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy.sa import *
&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy import env
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("Spatial")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("\n\nCalculate Slope Factor of Safety")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Grids
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; degreesSlope = Raster(r"C:\gtemp\FS_test\slope_degree")
&amp;nbsp;&amp;nbsp;&amp;nbsp; totalSoilThickness = Raster(r"C:\gtemp\FS_test\soildepth")
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilThickness = Raster(r"C:\gtemp\FS_test\dw")
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeRootStrength = Raster(r"C:\gtemp\FS_test\rootcohesion")
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeSurcharge = Raster(r"C:\gtemp\FS_test\surcharge")
&amp;nbsp;&amp;nbsp;&amp;nbsp; moistSoilUnitWeight = Raster(r"C:\gtemp\FS_test\moist_uw")
&amp;nbsp;&amp;nbsp;&amp;nbsp; numerator = "numerator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; denominator = "denominator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = "result"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Constants...
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; soilCohesion = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; effectiveInternalAngleofFriction = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; drySoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; waterUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; rastercalc = r"C:\gtemp\FS_test\dwrastercalc"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.cellSize = "MAXOF"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.extent = "MAXOF"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; numerator =((treeRootStrength + soilCohesion + Square(Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness)+ (saturatedSoilUnitWeight-waterUnitWeight)*saturatedSoilThickness)*Tan(effectiveInternalAngleofFriction)))

&amp;nbsp;&amp;nbsp;&amp;nbsp; denominator =((Sin(degreesSlope)*Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness) + drySoilUnitWeight * saturatedSoilThickness), denominator)
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; result =(numerator/denominator)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.save(rastercalc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Raster Calculator
&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.gp.RasterCalculator_sa("treeRootStrength + soilCohesion + Square(Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness)+ (saturatedSoilUnitWeigh-waterUnitWeight)*saturatedSoilThickness)*Tan(effectiveInternalAngleofFriction))/((Sin(degreesSlope)*Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness) + drySoilUnitWeight * saturatedSoilThickness))", rastercalc)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Done!")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except arcpy.ExecuteError: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = arcpy.GetMessages(2) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:52:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73807#M6041</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2021-12-10T22:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73808#M6042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;OK, I removed the raster calculator functions from the script.&amp;nbsp; According to the literature I can use raster calculator like expression (+,-,/...) as long as I cast the raster as 'rasters'.&amp;nbsp; I can get something like the below to work without error, but I cant get passed 'numerator' in the code below without getting the cell size and extent not set error.&lt;BR /&gt; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Both you and the parser will have a better chance of getting it right (or at least isolate the issues)&amp;nbsp; if you break this up into smaller chunks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
x1 =treeRootStrength + soilCohesion 
x2 = Square(Cos(degreesSlope)) * treeSurcharge + moistSoilUnitWeight * (totalSoilThickness - saturatedSoilThickness)
...
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've found this help article very, uh, helpful:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank" rel="nofollow noopener noreferrer"&gt;Building" rel="nofollow" target="_blank"&amp;gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00p60000000p000000.htm]Building&lt;/A&gt;&lt;SPAN&gt; Complex Statements&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73808#M6042</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-10T22:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73809#M6043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like there may be a bug with "MAXOF" &amp;amp; "MINOF" properties.&amp;nbsp; I tested this and always received a Runtime Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: No CellSize and Extent set&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you set the 'arcpy.env.cellSize' and 'arcpy.env.extent' to a raster, or to a constant (i.e. 10) the code should work.&amp;nbsp; You may want to report this issue to Tech Support.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 18:21:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73809#M6043</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-05-11T18:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73810#M6044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Jake.&amp;nbsp; Setting the env properties to a grid worked.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 18:38:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73810#M6044</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2012-05-11T18:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: error message at raster calculator</title>
      <link>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73811#M6045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Now that I got my tool running as a standalone script I set it to work as an ArcToolbox tool.&amp;nbsp; It throws an error&amp;nbsp; at line 62 (numerator) where the standalone does not...looks line another bug.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000824: The tool is not licensed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcPy ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy, os, sys, traceback
&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy.sa import *
&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy import env
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetProduct("ArcInfo")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("Spatial")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("\n\nCalculate Slope Factor of Safety")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("beta by Gerry Gabrisch, 5-4-2012")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get input parameters using ArcToolbox tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; degreesSlope = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; totalSoilThickness = arcpy.GetParameterAsText(1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilThickness = arcpy.GetParameterAsText(2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeRootStrength = arcpy.GetParameterAsText(3)
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeSurcharge = arcpy.GetParameterAsText(4)
&amp;nbsp;&amp;nbsp;&amp;nbsp; soilCohesion = float(arcpy.GetParameterAsText(5))
&amp;nbsp;&amp;nbsp;&amp;nbsp; effectiveInternalAngleofFriction = float(arcpy.GetParameterAsText(6))
&amp;nbsp;&amp;nbsp;&amp;nbsp; drySoilUnitWeight = float(arcpy.GetParameterAsText(7))
&amp;nbsp;&amp;nbsp;&amp;nbsp; moistSoilUnitWeight = arcpy.GetParameterAsText(8)
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilUnitWeight = float(arcpy.GetParameterAsText(9))
&amp;nbsp;&amp;nbsp;&amp;nbsp; waterUnitWeight = float(arcpy.GetParameterAsText(10))
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; rastercalc = arcpy.GetParameterAsText(11)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ##Use For hardcoding
&amp;nbsp;&amp;nbsp;&amp;nbsp; ##Grids
&amp;nbsp;&amp;nbsp;&amp;nbsp; #degreesSlope = r"C:\gtemp\FS_test\slope_degree"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #totalSoilThickness = r"C:\gtemp\FS_test\soildepth"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #saturatedSoilThickness = r"C:\gtemp\FS_test\dw"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #treeRootStrength = r"C:\gtemp\FS_test\rootcohesion"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #treeSurcharge = r"C:\gtemp\FS_test\surcharge"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #moistSoilUnitWeight = r"C:\gtemp\FS_test\moist_uw"
&amp;nbsp;&amp;nbsp;&amp;nbsp; ##Constants...
&amp;nbsp;&amp;nbsp;&amp;nbsp; #soilCohesion = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; #effectiveInternalAngleofFriction = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; #drySoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; #saturatedSoilUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; #waterUnitWeight = 10.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set the output cell size,&amp;nbsp; mask, and cell registration...
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.cellSize = degreesSlope
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.extent = degreesSlope
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.snapeRaster = degreesSlope
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Cast input rasters to in-memory raster layers...
&amp;nbsp;&amp;nbsp;&amp;nbsp; degreesSlope = Raster(degreesSlope)
&amp;nbsp;&amp;nbsp;&amp;nbsp; totalSoilThickness = Raster(totalSoilThickness)
&amp;nbsp;&amp;nbsp;&amp;nbsp; saturatedSoilThickness = Raster(saturatedSoilThickness)
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeRootStrength = Raster(treeRootStrength)
&amp;nbsp;&amp;nbsp;&amp;nbsp; treeSurcharge = Raster(treeSurcharge)
&amp;nbsp;&amp;nbsp;&amp;nbsp; moistSoilUnitWeight = Raster(moistSoilUnitWeight)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; numerator = "numerator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; denominator = "denominator"
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = "result"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; numerator =(treeRootStrength + soilCohesion + Square(Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness)+ (saturatedSoilUnitWeight-waterUnitWeight)*saturatedSoilThickness)*Tan(effectiveInternalAngleofFriction))
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; denominator =((Sin(degreesSlope)*Cos(degreesSlope))*(treeSurcharge + moistSoilUnitWeight*(totalSoilThickness - saturatedSoilThickness) + drySoilUnitWeight * saturatedSoilThickness))
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Do the last division....
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = numerator/denominator
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Save the in-memory results to disk...
&amp;nbsp;&amp;nbsp;&amp;nbsp; result.save(rastercalc)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Done!")
#Catch ESRI errors here...&amp;nbsp; 
except arcpy.ExecuteError: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = arcpy.GetMessages(2) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
#Catch Python errors here...
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:52:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-at-raster-calculator/m-p/73811#M6045</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2021-12-10T22:52:11Z</dc:date>
    </item>
  </channel>
</rss>

