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.
oi_recode_road_class(osm_sf, del=FALSE)
A sf
and data.frame
object containing OpenStreetMap
infrastructure data, obtained from the
osmextract
function.
If TRUE, will remove roads not recategorised by the function into one of the pre-set definitions.
The osm_sf
simple features data frame is returned with
additional columns openinfra_road_class and openinfra_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 |
Note: the osm_sf
must contain the following tags:
c("highway", "oneway")
library(sf)
internal_data = example_data
output = oi_recode_road_class(internal_data, del = FALSE)
# Quick plot:
plot(output["openinfra_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(openinfra_road_desc)) +
# tmap::tm_lines(col = "openinfra_road_desc", title.col = "Road class") +
# tmap::tm_layout(legend.bg.color = "white")