Determines road classification defined by Chan and Cooper's work.
Specifically re-classifies roads as one of 8 road classes (0-7) specified in the following table,
depending on each features highway=
key values.
recode_road_class(osm_sf)
A sf
and data.frame
object containing OpenStreetMap infrastructure data, obtained from the osmextract
function.
The osm_sf
simple features data frame is returned with additional columns road_class and road_desc based on Chan and Cooper's road classifications.
Re-classifies data based on the following highway key values:
Road Class | Description | Selection from OSM |
7 | Motorways | highway = motorway OR highway = motorway_link |
6 | Non-residential Dual Carriageways | highway = trunk OR highway = trunk_link*manual classification needed |
5 | Residential Dual Carriageways | highway = trunk OR highway = trunk_link*manual classification needed |
4 | Primary Roads | highway = primary OR highway = primary_link OR (highway = trunk AND oneway = F) |
3 | Secondary Roads | highway = secondary OR highway = secondary_link |
2 | Tertiary Roads | highway = tertiary OR highway = tertiary_link |
1 | Local Roads | highway = living_street OR highway = residential OR highway = unclassified |
0 | Traffic-free Paths | highway = cycleway |
library(sf)
u_data_large = paste0("https://github.com/udsleeds/openinfra/releases",
"/download/v0.2/bbbike_leeds_27_6_22.geojson")
u_data_small = paste0("https://github.com/udsleeds/openinfra/releases",
"/download/v0.2/30_06_22_bbbike_LCC_func_example_5_75km.geojson")
internal_data = example_data
output = recode_road_class(internal_data)
# Quick plot:
plot(output["road_desc"], key.pos = 1)
# Advanced plot with tmap - un-comment following four lines to run!
# tmap_mode("view")
# tmap::tm_shape(output |> dplyr::select(road_desc)) +
# tmap::tm_lines(col = "road_desc", title.col = "Road class") +
# tmap::tm_layout(legend.bg.color = "white")