Removes interstitial (degree-2) nodes that merely shape the geometry of a
street, merging each maximal chain of such nodes into a single edge whose
geometry follows the original points and whose length is the sum of the
merged segments. Only true endpoints and intersections are kept as nodes.
Arguments
- g
An unsimplified osm_graph.
- edge_attr_aggs
Named list of functions combining the per-segment values of an edge attribute along each merged chain, e.g.
list(travel_time = sum, speed_kph = mean). The defaultNULLsumstravel_timeandpenaltywhen those columns exist (so routing weights stay consistent); passlist()to aggregate nothing. Each function receives the segment values of one merged edge and must return a single value.
Value
A simplified osm_graph (with meta$simplified = TRUE).
Details
The topology walk is performed by the Rust core; geometry is rebuilt with
sf. Downloaded graphs are unsimplified by default; this is the standard
cleanup step before analysis.
Every edge attribute column survives simplification: a merged edge takes
the value of its first segment, except for columns named in
edge_attr_aggs, whose per-segment values are combined by the given
function (as in OSMnx 2). length is always recomputed from the merged
geometry unless an explicit length aggregator is supplied, and
n_segments records how many segments each edge merged.
References
osmnxr is an R port of OSMnx. If you use it, please cite:
Boeing, G. (2025). Modeling and analyzing urban networks and amenities with OSMnx. Geographical Analysis, 57(4), 567–577. doi:10.1111/gean.70009
Examples
g <- example_osm_graph()
ox_simplify(g) # already simplified: returned unchanged
#> ℹ Graph is already simplified; returning unchanged.
#>
#> ── osm_graph ───────────────────────────────────────────────────────────────────
#> 16 nodes, 48 edges
#> Network type: "drive"
#> Simplified: TRUE
#> CRS: "EPSG:3857"