Skip to contents

Extract the node or edge data from a spatial network

Usage

node_data(x, focused = TRUE)

edge_data(x, focused = TRUE, require_sf = FALSE)

Arguments

x

An object of class sfnetwork.

focused

Should only features that are in focus be extracted? Defaults to TRUE. See focus for more information on focused networks.

require_sf

Is an sf object required? This will make extraction of edge data fail if the edges are spatially implicit. Defaults to FALSE.

Value

For the nodes, always an object of class sf. For the edges, an object of class sf if the edges are spatially explicit, and an object of class tibble if the edges are spatially implicity and require_sf = FALSE.

Examples

net = as_sfnetwork(roxel[1:10, ])
node_data(net)
#> Simple feature collection with 20 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 7.525978 ymin: 51.94779 xmax: 7.543685 ymax: 51.95867
#> Geodetic CRS:  WGS 84
#> # A tibble: 20 × 1
#>               geometry
#>  *         <POINT [°]>
#>  1 (7.538109 51.95286)
#>  2 (7.537867 51.95282)
#>  3 (7.537815 51.95867)
#>  4 (7.537015 51.95848)
#>  5 (7.533441 51.95578)
#>  6 (7.533415 51.95561)
#>  7 (7.525977 51.95283)
#>  8 (7.526581 51.95293)
#>  9 (7.532301 51.95559)
#> 10 (7.532142 51.95589)
#> 11 (7.543404 51.94779)
#> 12  (7.543685 51.9479)
#> 13 (7.537675 51.95689)
#> 14 (7.537904 51.95656)
#> 15  (7.539105 51.9504)
#> 16 (7.540105 51.95058)
#> 17 (7.534875 51.95795)
#> 18 (7.533743 51.95769)
#> 19 (7.532465 51.95424)
#> 20 (7.532441 51.95482)
edge_data(net)
#> Simple feature collection with 10 features and 4 fields
#> Attribute-geometry relationships: constant (2), NA's (2)
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 7.525978 ymin: 51.94779 xmax: 7.543685 ymax: 51.95867
#> Geodetic CRS:  WGS 84
#> # A tibble: 10 × 5
#>     from    to name                              type                   geometry
#>    <int> <int> <chr>                             <chr>          <LINESTRING [°]>
#>  1     1     2 Hagemanns Kämpken                 resi… (7.538109 51.95286, 7.53…
#>  2     3     4 Stiegkamp                         resi… (7.537815 51.95867, 7.53…
#>  3     5     6 Havixbecker Straße                resi… (7.533441 51.95578, 7.53…
#>  4     7     8 Holzschuhmacherweg                resi… (7.525977 51.95283, 7.52…
#>  5     9    10 Annette-von-Droste-Hülshoff-Stra… seco… (7.532301 51.95559, 7.53…
#>  6    11    12 NA                                foot… (7.543404 51.94779, 7.54…
#>  7    13    14 Deermannskamp                     resi… (7.537675 51.95689, 7.53…
#>  8    15    16 Lindenstraße                      resi… (7.539105 51.9504, 7.540…
#>  9    17    18 NA                                NA    (7.534875 51.95795, 7.53…
#> 10    19    20 Annette-von-Droste-Hülshoff-Stra… seco… (7.532465 51.95424, 7.53…