# [R-sig-Geo] Anysotropic distance using gdistance

Francisco Moreira franciscodmoreira at gmail.com
Wed Feb 10 18:45:54 CET 2016

```Dear all,

I'm having a problem using the gdistance package to compute anysotropic
distances. Basically, I'm trying to use an exponential function to compute
the accumulated cost surface to predict the dispersion of an animal based
on slope. My problem is that, for whatever reason, the package always does
the absolute of the slope whether I use the abs() function (as in the
example given in the package) or not. However, I want negative slope values
to be increasingly easier to cross (unlike humans). Basically it's an
exponential function that tends to infinite permeability as we approach a
-90º slope and 0 in the 90º slope. I made a little example to illustrate my
problem using the package’s data:

library(gdistance)

library(raster)

r <- raster(system.file("external/maungawhau.grd", package="gdistance"))

plot(r)

altDiff <- function(x){x - x}

hd <- transition(r, altDiff, 8, symm=FALSE)

slope <- geoCorrection(hd)

speed <- slope

function to a exponencial to illustrate the function I'd like to apply

Conductance <- geoCorrection(speed)

A <- cbind(2667675, 6478975)

cost_dist<-accCost(Conductance, A)

B <- cbind(2667675, 6478985)

C <- cbind(2667675, 6478965)

extract(cost_dist, B)
1.527031

extract(cost_dist, C)
1.527031

Basically, when I check the value of accCost from point A (altitude = 153)
to points B (altitude = 149) or C (altitude = 157), I get the same cost for
both of them. And I get the same value if I add abs() to the slope in the
function. If I understand this correctly, this shouldn’t be the case
considering the function I’m using and the fact that the slope is negative
for B, and positive for C.

Any ideas on how to solve this problem? Is it possible to do what I want it
to do? Any suggestion would be highly appreciated.

Best regards,

Francisco

[[alternative HTML version deleted]]

```