R/osm_cleaning_functions.R
osm_get_junctions.RdGets junction points from route networks, building on functions in the
stplanr package: https://github.com/ropensci/stplanr/blob/master/R/rnet-clean.R
osm_get_junctions(x, method = "stplanr", overline = FALSE)
| x | a SF data frame of OSM linestrings |
|---|---|
| method | which method to use? The default, "stplanr" uses the
|
| overline | should the route network be pre-processed with the overline function? |
Returns an SF data frame of POINTS
This function finds all junction points in a road network, i.e. where two roads meet. It excludes road crossings e.g. bridges.
Other OSM:
cluster_junction(),
line_segment_sf(),
nn_line(),
nn_point(),
osm_consolidate(),
osm_main_roads()
x = osm_main_roads(tc_data_osm) class(x$geometry) #> [1] "sfc_LINESTRING" "sfc" junctions = osm_get_junctions(x) boundary_points = stplanr::rnet_get_nodes(x) summary(duplicated(boundary_points)) #> Mode FALSE #> logical 125 junctions2 = osm_get_junctions(x, method = "duplicates") #> Warning: repeating attributes for all sub-geometries for which they may not be constant length(junctions) #> [1] 50 length(junctions2) #> [1] 107 plot(x$geometry, col = "grey") plot(junctions, add = TRUE) plot(junctions2, add = TRUE, col = "red", cex = 0.5)![]()