Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rSPDistance

Randomized shortest path distance


Description

Calculates the randomized shortest path distance between points.

Usage

rSPDistance(x, from, to, theta, totalNet = "net", method = 1)

Arguments

x

TransitionLayer object

from

point locations coordinates (of SpatialPoints, matrix or numeric class)

to

point locations coordinates (of SpatialPoints, matrix or numeric class)

theta

theta is the degree from which the path randomly deviates from the shortest path, 0 < theta < 20

totalNet

total or net movements between cells

method

method 1 (as defined in Saerens et al.) or method 2 (a modified version, see below in Details)

Details

The function implements the algorithm given by Saerens et al. (2009).

Method 1 implements the method as it is. Method 2 uses W = exp(-theta * ln(P)).

Value

distance matrix (S3 class dist or matrix)

Author(s)

Jacob van Etten

References

Saerens M., L. Yen, F. Fouss, and Y. Achbany. 2009. Randomized shortest-path problems: two related models. Neural Computation, 21(8):2363-2404.

See Also

Examples

#Create a new raster and set all its values to unity.
r <- raster(nrows=18, ncols=36) 
r <- setValues(r,rep(1,ncell(raster)))

#Create a Transition object from the raster
tr <- transition(r,mean,4)

#Create two sets of coordinates
sP1 <- SpatialPoints(cbind(c(65,5,-65),c(55,35,-35)))
sP2 <- SpatialPoints(cbind(c(50,15,-40),c(80,20,-5)))

#Calculate the RSP distance between the points
rSPDistance(tr, sP1, sP2, 1)

gdistance

Distances and Routes on Geographical Grids

v1.3-6
GPL (>= 2)
Authors
Jacob van Etten [aut] (<https://orcid.org/0000-0001-7554-2558>), Kauê de Sousa [cre, ctb] (<https://orcid.org/0000-0002-7571-7845>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.