Learn R Programming

sfnetworks (version 0.2.0)

sfnetwork: Create an sfnetwork object

Description

sfnetwork is a tidy data structure for spatial networks. It extends the graph manipulation functionalities of the tidygraph-package package into the domain of geospatial networks, where nodes are embedded in geographical space. It subclasses tbl_graph, and therefore all of tidygraphs functions should work as expected, without any conversion. Just as with a tbl_graph, the nodes are activated by default. The context can be changed using the activate verb and affects all subsequent operations. In sfnetworks, the nodes are handled as being an sf object with only POINT geometries, and can always be extracted with st_as_sf when activated. The edges can be handled as being an sf object with only LINESTRING geometries, but this is optional. When the edges do not have an explicit spatial component, they can always be extracted with as_tibble when activated.

Usage

sfnetwork(nodes, edges, directed = TRUE, ...)

Arguments

nodes

An object containing information about the nodes in the network. The nodes should contain spatial information, either by being an sf object with only POINT geometries, or by being convertable to such an object with st_as_sf.

edges

An object containing information about the edges in the network. This object may contain explicit spatial information by being an sf object with only LINESTRING geometries. However, this is optional. It may also be a regular data.frame or tbl_df object. In any case, the terminal 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.

directed

Should the constructed network be directed? Defaults to TRUE.

...

Arguments passed on to st_as_sf, when converting the nodes to an sf object.

Value

An object of class sfnetwork.