View source: R/mat_cost_dist.R
mat_cost_dist | R Documentation |
The function computes cost-distances associated to least cost paths between point pairs on a raster with specified cost values.
mat_cost_dist( raster, pts, cost, method = "gdistance", return = "mat", direction = 8, parallel.java = 1, alloc_ram = NULL )
raster |
A parameter indicating the raster file on which cost distances are computed. It can be:
All the raster cell values must be present in the column 'code' from
|
pts |
A parameter indicating the points between which cost distances are computed. It can be either:
The point coordinates must be in the same spatial coordinate reference system as the raster file. |
cost |
A
|
method |
A character string indicating the method used to compute the cost distances. It must be:
|
return |
A character string indicating whether the returned object is a
|
direction |
An integer (4, 8, 16) indicating the directions in which
movement can take place from a cell. Only used when |
parallel.java |
An integer indicating how many computer cores are used
to run the .jar file. By default, |
alloc_ram |
(optional, default = NULL) Integer or numeric value indicating RAM gigabytes allocated to the java process when used. Increasing this value can speed up the computations. Too large values may not be compatible with your machine settings. |
The function returns:
If return="mat"
, a pairwise matrix
with cost-distance
values between points.
If return="df"
, an object of type data.frame
with three columns:
from: A character string indicating the ID of the point of origin.
to: A character string indicating the ID of the point of destination.
cost_dist: A numeric indicating the accumulated cost-distance along the least-cost path between point ID1 and point ID2.
P. Savary
## Not run: x <- raster::raster(ncol=10, nrow=10, xmn=0, xmx=100, ymn=0, ymx=100) raster::values(x) <- sample(c(1,2,3,4), size = 100, replace = TRUE) pts <- data.frame(ID = 1:4, x = c(10, 90, 10, 90), y = c(90, 10, 10, 90)) cost <- data.frame(code = 1:4, cost = c(1, 10, 100, 1000)) mat_cost_dist(raster = x, pts = pts, cost = cost, method = "gdistance") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.