as_tibble: Extract the active element of a sfnetwork as spatial tibble

as_tibbleR Documentation

Extract the active element of a sfnetwork as spatial tibble

Description

The sfnetwork method for as_tibble is conceptually different. Whenever a geometry list column is present, it will by default return what we call a 'spatial tibble'. With that we mean an object of class c('sf', 'tbl_df') instead of an object of class 'tbl_df'. This little conceptual trick is essential for how tidyverse functions handle sfnetwork objects, i.e. always using the corresponding sf method if present. When using as_tibble on sfnetwork objects directly as a user, you can disable this behaviour by setting spatial = FALSE.

Usage

## S3 method for class 'sfnetwork'
as_tibble(x, active = NULL, spatial = TRUE, ...)

Arguments

x

An object of class sfnetwork.

active

Which network element (i.e. nodes or edges) to activate before extracting. If NULL, it will be set to the current active element of the given network. Defaults to NULL.

spatial

Should the extracted tibble be a 'spatial tibble', i.e. an object of class c('sf', 'tbl_df'), if it contains a geometry list column. Defaults to TRUE.

...

Arguments passed on to as_tibble.

Value

The active element of the network as an object of class tibble.

Examples

library(tibble, quietly = TRUE)

net = as_sfnetwork(roxel)

# Extract the active network element as a spatial tibble.
as_tibble(net)

# Extract any network element as a spatial tibble.
as_tibble(net, "edges")

# Extract the active network element as a regular tibble.
as_tibble(net, spatial = FALSE)


sfnetworks documentation built on March 18, 2022, 7:49 p.m.