knitr::opts_chunk$set( collapse = TRUE, warning = TRUE, message = TRUE, width = 120, comment = "#>" )
R package for probabilistic OpenStreetMap routing
devtools::install_github ('osm-router/osmprob')
devtools::load_all ('.', export_all=FALSE) devtools::document ('.') devtools::check ('.')
Downloading and preprocessing the graph is done in the function download_graph
()
. To prepare the graph for routing, all non-accessible edges are removed and
vertices not needed to maintain the graph's topology are removed. The resulting
data is a list
containing the original graph, the compact graph and a map of
edge IDs that connect the two graphs to each other. A preprocessed sample graph
can be acessed with road_data_sample
. After the preprocessing and routing is
done, plot_map ()
can be used to display the traversal probabilities and
shortest path in a shiny
/leaflet
web app.
To load, process and display the sample graph included in the package, run
graph <- road_data_sample start_pt <- c (11.603, 48.163) end_pt <- c (11.608, 48.167) pts <- select_vertices_by_coordinates (graph, start_pt, end_pt) route_start <- pts[1] route_end <- pts [2] path <- get_shortest_path (graph, route_start, route_end) prob <- get_probability (graph, route_start, route_end, eta = 0.6) plot_map (prob, path)
devtools::load_all (export_all = FALSE) start_pt <- c (11.603, 48.163) end_pt <- c (11.608, 48.167) graph <- download_graph (start_pt, end_pt) pts <- select_vertices_by_coordinates (graph, start_pt, end_pt) route_start <- pts[1] route_end <- pts [2] path <- get_shortest_path (graph, route_start, route_end) prob <- get_probability (graph, route_start, route_end, eta = 0.6) plot_map (prob, path)
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.