A sample street network for Bristol, U.K., from the Ordnance Survey.
A Simple Features
motorways in Bristol, UK.
Input data downloaded from https://osdatahub.os.uk/downloads/open, To download the data from that page click on the tick box next to 'OS Open Roads', scroll to the bottom, click 'Continue' and complete the form on the subsequent page. This dataset is open access and can be used under the Open Government License and must be cited as follows: Contains OS data © Crown copyright and database right (2017)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
## Not run: library(sf) library(dplyr) # data must be unzipped here # os_roads <- sf::read_sf("~/data/ST_RoadLink.shp") # u <- "https://opendata.arcgis.com/datasets/686603e943f948acaa13fb5d2b0f1275_4.kml" # lads <- sf::read_sf(u) # mapview::mapview(lads) # bristol_pol <- dplyr::filter(lads, grepl("Bristol", lad16nm)) # os_roads <- st_transform(os_roads, st_crs(lads) # os_roads_bristol <- os_roads[bristol_pol, ] %>% # dplyr::filter(class == "Motorway" & roadNumber != "M32") %>% # st_zm(drop = TRUE) # mapview::mapview(os_roads_bristol) ## End(Not run) # Converting this 'sf data.frame' to a 'dodgr' network requires manual # specification of weighting profile: colnm <- "formOfWay" # name of column used to determine weights wts <- data.frame (name = "custom", way = unique (os_roads_bristol [[colnm]]), value = c (0.1, 0.2, 0.8, 1)) net <- weight_streetnet (os_roads_bristol, wt_profile = wts, type_col = colnm, id_col = "identifier") # 'id_col' tells the function which column to use to attribute IDs of ways
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.