bind_spatial: Add nodes or edges to a spatial network.

bind_spatialR Documentation

Add nodes or edges to a spatial network.

Description

These functions are the spatially aware versions of tidygraph's bind_nodes and bind_edges that allow you to add rows to the nodes or edges tables in a sfnetwork object. As with bind_rows columns are matched by name and filled with NA if the column does not exist in some instances.

Usage

bind_spatial_nodes(.data, ...)

bind_spatial_edges(.data, ..., node_key = "name", force = FALSE)

Arguments

.data

An object of class sfnetwork.

...

One or more objects of class sf containing the nodes or edges to be added.

node_key

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

force

Should network validity checks be skipped? Defaults to FALSE, meaning that network validity checks are executed after binding edges, making sure that boundary points of edges match their corresponding node coordinates.

Value

An object of class sfnetwork with added nodes or edges.

Examples

library(sf, quietly = TRUE)
library(dplyr, quietly = TRUE)

net = roxel |>
  slice(c(1:2)) |>
  st_transform(3035) |>
  as_sfnetwork()

pts = roxel |>
  slice(c(3:4)) |>
  st_transform(3035) |>
  st_centroid()

bind_spatial_nodes(net, pts)


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.