View source: R/create_stochastic_lcp.R
create_stochastic_lcp  R Documentation 
Calculates a Stochastic Least Cost Path from an origin location to a destination location by randomly determining the neighbourhood adjacency. Method based on Pinto and Keitt (2009). Applies Dijkstra's algorithm. See details for more information.
create_stochastic_lcp( cost_surface, origin, destination, directional = FALSE, percent_quantile )
cost_surface 

origin 

destination 

directional 

percent_quantile 

The calculation of a stochastic least cost path is based on the method proposed by Pinto and Keitt (2009). Instead of using a static neighbourhood (for example as supplied in the neighbours function in the create_slope_cs), the neighbourhood is redefined such that the adjacency is nondeterministic and is instead determined randomly based on the threshold value.
The algorithm proceeds as follows:
1. If threshold_quantile is not supplied, draw a random value from a uniform distribution between the minimum value and maximum value in the supplied cost surface. If threshold_quantile is supplied, draw a random value between the minimum value in the supplied cost surface and the percent quantile as calculated using the supplied percent_quantile
2. Replace values in cost surface below the random value with 0. This ensures that the conductance between the neighbours are 0, and thus deemed nonadjacent.
Supplying a percent_quantile of 0 is equivalent to calculating the nonstochastic least cost path. That is, if the supplied percent_quantile is 0, then no values are below this value and thus no values will be replaced with 0 (see step 2). This therefore does not change the neigbourhood adjacency.
Supplying a percent_quantile of 1 is equivalent to not supplying a percent_quantile value at all. That is, if the supplied percent_quantile is 1, then the possible random threshold value is between the minimum and maximum values in the cost surface.
The closer the percent_quantile is to 0, the less the stochastic least cost paths are expected to deviate from the least cost path. For example, a percent_quantile value of 0.2 will result in the threshold being a random value between the minimum value in the cost surface and the 0.2 percent quantile of the values in the cost surface. All values in the cost surface below the threshold will be replaced with 0 (i.e. the neighbours are no longer adjacent). In contrast, a percent_quantile value of 0.8 will result in the threshold being a random value between the minimum value in the cost surface and the 0.8 percent quantile of the values in the cost surface. In this case, there is greater probability that the random value will result in an increased number of values in the cost surface being replaced with 0.
SpatialLinesDataFrame
(sp package) of length 1 if directional argument is TRUE or 2 if directional argument is FALSE. The resultant object is the shortest route (i.e. least cost) between origin and destination after a random threshold has been applied to the supplied TransitionLayer
.
Joseph Lewis
Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik. 1: 269271.
Pinto, N., Keitt, T.H. (2009) Beyond the leastcost path: evaluating corridor redundancy using a graphtheoretic approach. Landscape Ecol 24, 253266 doi: 10.1007/s109800089303y
r < raster::raster(nrow=50, ncol=50, xmn=0, xmx=50, ymn=0, ymx=50, crs='+proj=utm') r[] < stats::runif(1:length(r)) slope_cs < create_slope_cs(r, cost_function = 'tobler') locs < sp::spsample(as(raster::extent(r), 'SpatialPolygons'),n=2,'random') stochastic_lcp < create_stochastic_lcp(cost_surface = slope_cs, origin = locs[1,], destination = locs[2,], directional = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.