Wrappers around the shortest path calculation functionalities in
igraph
, allowing to
provide any geospatial point as `from` argument and any set of geospatial
points as `to` argument.
st_shortest_paths(
graph,
from,
to = V(graph),
weights = NULL,
snap = "nearest_node",
...
)st_all_shortest_paths(
graph,
from,
to = V(graph),
weights = NULL,
snap = "nearest_node"
)
st_network_distance(
graph,
from = V(graph),
to = V(graph),
weights = NULL,
snap = "nearest_node",
...
)
An object of class sfnetwork
.
The geospatial point from which the shortest paths will be
calculated. Can be an object an object of class sf
or
sfc
, containing a single feature. When multiple features
are given, only the first one is taken.
Alternatively, it can be a numeric constant, referring to the index of the
node from which the shortest paths will be calculated. Only in the case of
st_network_distances
the restriction of a single feature does not
apply. Then, it can also be an sf
or sfc
object with multiple features, or alternatively a vector of node indices.
The (set of) geospatial point(s) to which the shortest paths will be
calculated. Can be an object of class sfg
, or an object
of class sf
or sfc
. Alternatively, it can
be a numeric vector, containing the indices of the nodes to which the
shortest paths will be calculated. By default, all nodes in the network are
included.
Possibly a numeric vector giving edge weights, or a column
name referring to an attribute column in the edges table that contains those
weights. If set to NULL
and the network has a column named 'weight' in
the edges table, then those values are used. If set to NA
then no
weights are used (even if the edges have a weight attribute).
Which technique to use for snapping given geospatial points to the network. Can be either 'nearest_node', which will use the nearest node to the given point, or 'nearest_point_on_edge', which will use the nearest location on the nearest edge to the given point. Defaults to 'nearest_node', which is currently the only implemented option.
Arguments passed on to the corresponding
igraph
function.
The return value is the same as for the corresponding igraph
function, see here
.
st_shortest_paths
: Wrapper around
igraph::shortest_paths
.
st_all_shortest_paths
: Wrapper around
igraph::all_shortest_paths
.
st_network_distance
: Wrapper around igraph::distances
.
See the igraph
documentation.