| mc_paths | R Documentation |
Computes least-cost path(s) (LCPs) from an origin to one or more destination
locations, reusing the graph stored in a mc_surface object.
Because terrain costs are anisotropic, the path back from a destination to
the origin can differ from the outward path; set return.base = TRUE
to also compute the return paths.
mc_paths(surface, origin, destin, return.base = FALSE, time = "h")
surface |
a |
origin |
single origin location (sf points, SpatVector, or legacy SpatialPointsDataFrame); if more than one feature is supplied, the first is used. |
destin |
destination location(s) (same accepted classes). |
return.base |
TRUE or FALSE (default): also compute the least-cost paths from each destination back to the origin. |
time |
unit for time-based cost functions: "h" (hours, default) or "m" (minutes). |
Each returned path carries its accumulated cost (in the unit of the
surface's cost function; for time-based functions, in the unit selected via
time) and its length. For time-based functions a
cost_hms column additionally expresses the cost in sexagesimal format
(HH:MM:SS). The same attributes are appended to the returned copy of the
destination locations, mirroring the dest.loc.w.cost output of
movecost <= 2.x.
An object of class movecost_paths, a list with components
paths: sf lines with cost, length and
(for time-based functions) cost_hms attributes;
paths.back: sf lines of the return paths (NULL unless
return.base = TRUE);
destin: copy of the destination locations with cost
(and cost_hms) appended;
origin: the origin (sf);
metadata used by the plot method.
Plot it at any time with plot() (see
plot.movecost_paths); no computation is re-run.
mc_surface, plot.movecost_paths,
mc_rank, mc_network
dtm <- mc_volc()
start <- mc_volc_loc()
destin <- mc_destin_loc()
surf <- mc_surface(dtm, funct = "t", move = 8)
lcp <- mc_paths(surf, origin = start, destin = destin)
lcp$paths # sf object: costs, lengths, geometries
plot(lcp)
# paths back to the origin (anisotropy makes them differ):
lcp2 <- mc_paths(surf, start, destin[2, ], return.base = TRUE)
plot(lcp2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.