ox_consolidate_intersections: Consolidate nearby intersections

View source: R/simplify.R

ox_consolidate_intersectionsR Documentation

Consolidate nearby intersections

Description

Merges groups of nodes lying within tolerance of one another into single nodes placed at the group centroid, then rewrites edges to the consolidated nodes and drops the resulting self-loops. Useful for collapsing the multiple OSM nodes that represent one complex junction (e.g. dual carriageways).

Usage

ox_consolidate_intersections(g, tolerance = 10)

Arguments

g

An osm_graph.

tolerance

Distance below which nodes are merged, in CRS units. Default 10.

Details

Clustering uses sf::st_is_within_distance(); connected components are found by the Rust core. tolerance is in the units of the graph CRS, so project the graph first (e.g. to a metric CRS) for a meaningful distance.

Value

A consolidated osm_graph (with meta$consolidated = TRUE).

Examples

g <- example_osm_graph(n = 4, spacing = 100)
# nothing is within 10 units here, so the graph is unchanged
ox_consolidate_intersections(g, tolerance = 10)

osmnxr documentation built on Oct. 20, 2026, 1:07 a.m.