Hi,
I am trying to perform an optimal path analysis using Tobler's Function, and I am having issues working with the raster calculator. My math look like this:
(1.0 / 1000) / (6 * Exp(-3.5 * Abs(Tan(("slope" * 3.14159)/180) + .05)))
This return values very close to 0 (e.g., 0.00014) when it finishes. From what I've read this looks like something I'm doing is causing issues using integers and floating-point values. Does anyone have help or advice they would be willing to share?
I am getting my workflow from this source The Basics of Least Cost Analysis for Archaeological Applications | Advances in Archaeological Pract...
Hey @ifarrell71
I would verify this by breaking down the large equation, and walking through it step-by-step in order to see where exactly it may be having the issue. Also, it may be worth trying to assign everything number as a floating point integer, something like this: (1.0 / 1000.0) / (6.0 * Exp(-3.5 * Abs(Tan(("slope" * 3.14159) / 180.0) + 0.05))) and seeing if this sets it into a good spot!
Cody
is your "slope" raster in degrees or radians? That can simplify the equation.
Also is "Exp" actually the correct incarnation or is it a substitute for the "power of"
Using python as an angle and a "slope" surface of 45 degrees, what is your expected answer?
slope = 45
(1.0 / 1000) / (6**(-3.5 * abs(tan(radians(slope)) + 0.05)))
0.7239454537426908
(1.0 / 1000) / (6 * exp(-3.5 * abs(tan(radians(slope)) + 0.05)))
0.00657477614286675
I will leave that for you to decide based on the book you are using.
Also two potentially wrong answers can result if your slope is already in radians and you try to incorporate the changes in either variant of the above
# ------- what happens when slope is already in radians and either is used ----
slope = radians(slope) # 45 degrees is now 0.7853981633974483 radians
# wrongly assuming slope is in degrees then trying to convert will make things
# worse using either equation variant
(1.0 / 1000) / (6**(-3.5 * abs(tan(radians(slope)) + 0.05)))
0.0014911191902071232
(1.0 / 1000) / (6 * exp(-3.5 * abs(tan(radians(slope)) + 0.05)))
0.00020829931476860165