dclapp62

Error: unsupported operand type(s) for /: 'str' and 'float' when converted to Python

Discussion created by dclapp62 on Jun 1, 2011
Latest reply on Jun 3, 2011 by dclapp62
Hi,

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.

# Calculate the slope across the surface.

arcpy.gp.Slope_sa(forest, forest_slope, "DEGREE", "1")

# Calculate the slope cost based upon a nonlinear trigonometric cost function.

arcpy.gp.RasterCalculator_sa("Sin((\"%forest_slope%\")/57.2958)*200", forest_slope_cost)

ERROR 000539: Error running expression: rcexec() <type 'exceptions.TypeError'>: unsupported operand type(s) for /: 'str' and 'float'

Failed to execute (RasterCalculator).

Outcomes