<?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: unsupported operand type(s) for /: 'str' and 'float' when converted to Pyt in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251546#M19376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would try using the commands outside of the Raster Calculator.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import sa
from arcpy.sa import *

arcpy.CheckOutExtension("spatial")

forest = r"c:\test.gdb\forest"

forest_slope = arcpy.sa.Slope(forest, "DEGREE", "1")
sin = arcpy.sa.Sin(forest_slope)
divide = arcpy.sa.Divide(sin, 57.2958)
multiply = arcpy.sa.Times(divide, 200)

multiply.save(r"c:\test.gdb\forest_slope_cost")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:28:58 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2021-12-11T12:28:58Z</dc:date>
    <item>
      <title>Error: unsupported operand type(s) for /: 'str' and 'float' when converted to Python</title>
      <link>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251545#M19375</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;BR /&gt;&lt;SPAN&gt;I converted a model to Python but I received an error message when trying to calculate slope cost. I believe that it has to do with Python treating the resulting slope as a string in the formula and that I need to somehow convert forest_slope from a string to a float but anything that I have tried does not seem to work. Any suggestions are appreciated. Forest is a DEM layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Calculate the slope across the surface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.Slope_sa(forest, forest_slope, "DEGREE", "1")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Calculate the slope cost based upon a nonlinear trigonometric cost function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.RasterCalculator_sa("Sin((\"%forest_slope%\")/57.2958)*200", forest_slope_cost)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: rcexec() &amp;lt;type 'exceptions.TypeError'&amp;gt;: unsupported operand type(s) for /: 'str' and 'float'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (RasterCalculator).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2011 14:57:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251545#M19375</guid>
      <dc:creator>DavidClapp</dc:creator>
      <dc:date>2011-06-01T14:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error: unsupported operand type(s) for /: 'str' and 'float' when converted to Pyt</title>
      <link>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251546#M19376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would try using the commands outside of the Raster Calculator.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import sa
from arcpy.sa import *

arcpy.CheckOutExtension("spatial")

forest = r"c:\test.gdb\forest"

forest_slope = arcpy.sa.Slope(forest, "DEGREE", "1")
sin = arcpy.sa.Sin(forest_slope)
divide = arcpy.sa.Divide(sin, 57.2958)
multiply = arcpy.sa.Times(divide, 200)

multiply.save(r"c:\test.gdb\forest_slope_cost")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:28:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251546#M19376</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T12:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error: unsupported operand type(s) for /: 'str' and 'float' when converted to Pyt</title>
      <link>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251547#M19377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This worked, it maintained the type raster. The conversion of the spatial analyst tools from Model Maker to Python results in script type outputs which caused the errors. Thanks much!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2011 14:58:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-unsupported-operand-type-s-for-str-and-float/m-p/251547#M19377</guid>
      <dc:creator>DavidClapp</dc:creator>
      <dc:date>2011-06-03T14:58:02Z</dc:date>
    </item>
  </channel>
</rss>

