sfnetwork
is a tidy data structure for geospatial networks. It extends
the graph manipulation functionalities of the
tidygraph-package
package into the domain of
geospatial networks, where the nodes and optionally also the edges are
embedded in geographical space, and enables to apply the spatial analytical
function from the sf-package
directly to the network.
sfnetwork(
nodes,
edges,
directed = TRUE,
node_key = "name",
edges_as_lines = NULL,
force = FALSE,
...
)
An object containing information about the nodes in the network.
The nodes should contain geospatial coordinates, either by being an sf
object with POINT
geometry features, or by being convertable to such an
object with st_as_sf
.
An object containing information about the edges in the network.
This object may contain explicit geospatial information by being an sf
object with LINESTRING
geometry features. However, this is optional. It
may also be a regular data.frame
or tbl_df
object. In any case,
the adjacent nodes of each edge must either be encoded in a to
and
from
column, or in the two first columns, as integers. These integers
refer to nodes indices, which in turn refer to the position of a node in the
nodes table.
Should the constructed network be directed? Defaults to
TRUE
.
The name of the column in the nodes table that character
represented to
and from
columns should be matched against. If
NA the first column is always chosen. This setting has no effect if to
and from
are given as integers. Defaults to "name"
.
Should the edges be spatially explicit, i.e. have
LINESTRING
geometries stored in a geometry list column? If NULL
,
this will be automatically defined, by setting the argument to TRUE
when the given edges object contains a geometry list column, and FALSE
otherwise. Defaults to NULL
.
Should network validity checks be skipped? Defaults to
FALSE
, meaning that network validity checks are executed when
constructing the network. These checks guarantee a valid spatial network
structure. For the nodes, this means that they all should have POINT
geometries. In the case of spatially explicit edges, it is also checked that
all edges have LINESTRING
geometries, nodes and edges have the same
CRS and boundary points of edges match their corresponding node coordinates.
These checks are important, but also time consuming. If you are already sure
your input data meet the requirements, the checks are unneccesary and can be
turned off to improve speed.
Arguments passed on to st_as_sf
, when
converting the nodes to an sf
object.
An object of class sfnetwork
.