ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
421 stars 66 forks source link

Function that returns junction points #357

Open Robinlovelace opened 5 years ago

Robinlovelace commented 5 years ago

This will be very useful for road safety research using a variety of spatial network data sources, including OSM (which has a junction column, but which may not always be marked as such).

The beginnings of a solution are shown below. Note that the main problem with this solution is that it also returns start points of lines (cul de sac):

library(stplanr)
# roads_key = readRDS(url("https://github.com/ropensci/stats19/releases/download/1.1.0/roads_key.Rds"))
roads_key = stplanr::osm_net_example
junctions_maybe = line2points(roads_key)
length(unique(junctions_maybe$geometry))
#> [1] 110
mapview::mapview(junctions_maybe)

roads_key$value = 1
roads_key_rnet = overline2(roads_key, attrib = "value")
#> 2019-10-24 12:44:22 constructing segments
#> 2019-10-24 12:44:22 building geometry
#> 2019-10-24 12:44:22 simplifying geometry
#> 2019-10-24 12:44:22 aggregating flows
#> 2019-10-24 12:44:22 rejoining segments into linestrings
junctions_maybe2 = line2points(roads_key_rnet)
length(unique(junctions_maybe2$geometry))
#> [1] 104
mapview::mapview(junctions_maybe2)

Created on 2019-10-24 by the reprex package (v0.3.0)

mpadge commented 5 years ago

That's a cool idea, and ... (my standard response by now) ... easy to do with dodgr. Just convert to a dodgr network, make frequency tables for from and to nodes, and select all those with frequencies >= 3