Skip to contents

Subdivide edges by adding missing nodes, (optionally) simplify the network (see simplify_network()), remove pseudo-nodes, and discard all but the main connected component.

Usage

clean_network(network, simplify = TRUE)

Arguments

network

A network object

simplify

Whether the network should be simplified with simplify_network()

Value

A cleaned network object

Examples

if (!requireNamespace("CRiSpData", quietly = TRUE)) {
  message("Install CRiSpData from GitHub to run this example.")
} else {
  edges <- dplyr::bind_rows(CRiSpData::bucharest_osm$streets,
                            CRiSpData::bucharest_osm$railways)
  network <- sfnetworks::as_sfnetwork(edges, directed = FALSE)
  clean_network(network)
}
#> Warning: to_spatial_subdivision assumes attributes are constant over geometries
#> # A sfnetwork with 4875 nodes and 7265 edges
#> #
#> # CRS:  EPSG:32635 
#> #
#> # An undirected multigraph with 1 component with spatially explicit edges
#> #
#> # Node data: 4,875 × 1 (active)
#>             geometry
#>          <POINT [m]>
#> 1 (427853.8 4924451)
#> 2 (427348.7 4924016)
#> 3 (432564.3 4918306)
#> 4 (432099.2 4919990)
#> 5 (432328.7 4919554)
#> 6 (435628.7 4921177)
#> # ℹ 4,869 more rows
#> #
#> # Edge data: 7,265 × 4
#>    from    to type                                geometry
#>   <int> <int> <chr>                       <LINESTRING [m]>
#> 1  3094  3327 primary (419784.6 4914936, 419784.1 4914935)
#> 2   278  2044 primary     (426640 4924180, 426640 4924179)
#> 3  1145  1524 primary (425261.5 4919952, 425262.3 4919951)
#> # ℹ 7,262 more rows