| mc_comp | R Documentation |
Computes, for the same origin and destination(s), the least-cost paths
produced by two or more cost functions, so that route choice and cost can be
compared across cost models. One cost surface is built per function (this is
unavoidable, since each function defines its own graph weights), but each is
built once and all the remaining computation reuses it.
mc_comp(
dtm,
origin,
destin,
functs,
move = 16,
return.base = FALSE,
time = "h",
...
)
dtm |
Digital Terrain Model (SpatRaster, RasterLayer, or file path),
as in |
origin |
single origin location (sf points, SpatVector, or legacy SpatialPointsDataFrame). |
destin |
destination location(s) (same accepted classes). |
functs |
character vector of cost-function codes to compare (see
|
move |
number of directions in which cells are connected (4, 8, or 16; default 16). |
return.base |
TRUE or FALSE (default): also compute the paths back to the origin for each cost function. |
time |
unit for time-based cost functions: "h" (hours, default) or "m" (minutes). |
... |
further parameters passed to |
Note that costs produced by functions of different families (walking time, energy, abstract) are expressed in different units and are comparable in terms of route geometry, not of cost magnitude; the cost table returned reports the unit alongside each value.
An object of class movecost_comp, a list with components
paths: sf lines for all functions, with funct,
destination, cost, cost_unit, and length
attributes;
paths.back: return paths (NULL unless
return.base = TRUE);
cost.table: data frame summarising cost and length per
function and destination;
origin, destin: the input locations (sf);
metadata used by the plot method.
Plot it at any time with plot() (see
plot.movecost_comp); plot(x, type = "chart") compares
the path length and the cost across functions, as boxplots of their
distribution across destinations when three or more destinations are used
(the add.chart output of movecost <= 2.x), or as bars otherwise.
mc_surface, mc_paths,
plot.movecost_comp
dtm <- mc_volc()
start <- mc_volc_loc()
destin <- mc_destin_loc()
cmp <- mc_comp(dtm, origin = start, destin = destin[2, ],
functs = c("t", "ks", "mp"), move = 8)
cmp$cost.table
plot(cmp) # routes on the terrain
plot(cmp, type = "chart") # comparative bar chart
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.