| walk_shortest_path | R Documentation |
Finds the optimal walking route between an origin and destination across the
street graph using Dijkstra's algorithm compiled in Rust. Supports node IDs,
numeric coordinate vectors c(x, y), or sf point geometries.
walk_shortest_path(network, from, to)
network |
A |
from |
Origin location: either an integer node index, a numeric vector
|
to |
Destination location: either an integer node index, a numeric vector
|
A walk_path S3 object containing:
path_sf |
|
nodes_sf |
|
node_ids |
Sequence of node IDs visited. |
distance_m |
Total walking route distance in meters. |
time_s |
Total travel time in seconds at the network walking speed. |
time_min |
Total travel time in minutes. |
circuity |
Detour ratio (network path distance / straight-line Euclidean distance). |
from_node |
Resolved origin node index. |
to_node |
Resolved destination node index. |
network |
The input |
data(streets_cusco)
net <- walk_build_network(streets_cusco, verbose = FALSE)
orig <- sf::st_coordinates(net$nodes[net$nodes$is_giant, ])[1, 1:2]
dest <- sf::st_coordinates(net$nodes[net$nodes$is_giant, ])[50, 1:2]
p <- walk_shortest_path(net, from = orig, to = dest)
print(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.