cost_matrix  R Documentation 
Creates a cost based nearest neighbour matrix of k length for each provided location. This matrix can be used in the nb_matrix argument within the create_lcp_network function to calculate Least Cost Paths between origins and destinations.
cost_matrix(cost_surface, locations, k)
cost_surface 

locations 

k 

matrix
costbased k nearest neighbour for each location as specified in the locations argument. The resultant matrix
can be used in the nb_matrix argument within the create_lcp_network function.
Joseph Lewis
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=5,'regular') matrix < cost_matrix(slope_cs, locs, 2) lcp_network < create_lcp_network(slope_cs, locations = locs, nb_matrix = matrix, cost_distance = FALSE, parallel = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.