Learn R Programming

trafficCAR (version 0.1.0)

build_network: Build a road network graph from sf LINESTRING data

Description

Build a road network graph from sf LINESTRING data

Usage

build_network(
  roads_sf,
  crs_out = 3857,
  node_intersections = FALSE,
  snap_tol = 0,
  simplify = TRUE
)

Value

A list with components:

  • roads: cleaned sf object

  • nodes: sf POINT object with node_id

  • edges: sf LINESTRING object with from, to, length

  • graph: igraph object

  • A: sparse adjacency matrix

Arguments

roads_sf

An sf object with LINESTRING geometry

crs_out

Integer EPSG code for projected CRS

node_intersections

Logical; if TRUE, "node" the linework by splitting at interior intersections/junctions (via `sf::st_union()`), so that crossings and T-junctions become graph nodes even when they are not endpoints. This may increase the number of edge segments.

snap_tol

Nonnegative numeric; optional snapping tolerance (in projected CRS units) used to merge nearly identical endpoints. Use 0 to disable.

simplify

Logical; if TRUE, remove self-loops and parallel edges.