build_streetnet.Rd
Build a routable graph from a set of linestrings
build_streetnet(x, protect = NULL)
An object of class sf
with LINESTRING
or
MULTILINESTRING
geometries.
Set of points that protect their nearest linestring vertex
from being smoothed (see Details). That is, the closest linestring vertices
to these points are guaranteed to be a node in the resulting graph, even if
they are neither a pendant node nor a junction node. May be given either as
an object of class sf
or sfc
with POINT
geometries, or as a two-column numeric matrix containing respectively the
longitude and latitude coordinates of the points.
An object of class sfnetwork
.
Graph building is implemented as a step-wise process. The graph
will be directed, so first all linestring geometries of x
that are not
marked as being a oneway street (through the oneway attribute column if
present) are duplicated and reversed. Then, all the linestring geometries
are split such that their segments become separate linestring geometries
on their own. These serve as the edges in the initial graph, and their
endpoints become the nodes. Endpoints that are shared between multiple edges
become a single node, such that these edges are connected. Only the largest
connected component of the initial graph is preserved. Finally, the initial
graph is smoothed by removing all nodes that are neither a pendant node
(i.e. a node at the end of an edge without a connection to any other edge)
nor a junction node (i.e. a node that connects more than two edges) nor a
nearest node to any of the points passed to the protect
parameter.
Coordinates should be expressed in coordinate reference system EPSG:4326. The function assumes this to be true, and does not check for it.