Learn R Programming

sfnetworks (version 0.3.1)

spatial_shortest_paths: Shortest paths between points in geographical space

Description

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.

Usage

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", ... )

Arguments

graph

An object of class sfnetwork.

from

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.

to

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.

weights

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).

snap

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.

Value

The return value is the same as for the corresponding igraph function, see here.

Functions

  • 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.

Details

See the igraph documentation.