| Title: | Graphical User Interface for 'r5r' Router |
|---|---|
| Description: | Interactively build and explore public transit routes with 'r5r' package via a graphical user interface in a 'shiny' app. The underlying routing methods are described in Pereira et al. (2021) <doi:10.32866/001c.21262>. |
| Authors: | Egor Kotov [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-6690-5345>) |
| Maintainer: | Egor Kotov <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0.9000 |
| Built: | 2026-05-13 05:28:50 UTC |
| Source: | https://github.com/e-kotov/r5rgui |
This function launches a Shiny application that provides a graphical user interface for the 'r5r' package, allowing for interactive transit routing.
r5r_gui( r5r_network, center = NULL, zoom = NULL, departure_date = Sys.Date(), mode = c("WALK", "TRANSIT"), basemaps = list(Positron = mapgl::carto_style("positron"), `Dark Matter` = mapgl::carto_style("dark-matter"), Voyager = mapgl::carto_style("voyager")) )r5r_gui( r5r_network, center = NULL, zoom = NULL, departure_date = Sys.Date(), mode = c("WALK", "TRANSIT"), basemaps = list(Positron = mapgl::carto_style("positron"), `Dark Matter` = mapgl::carto_style("dark-matter"), Voyager = mapgl::carto_style("voyager")) )
r5r_network |
A pre-built 'r5r' network object, or a named list of such objects for comparison. If a list is provided, the list names will be used as labels in the GUI. If a single object is provided, its variable name will be used as the label. |
center |
A numeric vector of length 2, specifying the initial longitude and latitude for the map's center. If |
zoom |
An integer specifying the initial zoom level of the map. If |
departure_date |
A Date object specifying the initial departure date for the trip. Defaults to the current system date. |
mode |
A character vector specifying the initial transport modes. This is passed directly to the |
basemaps |
A named list of MapLibre style URLs (or style generator functions like |
This function does not return a value; it launches a Shiny application.
if (interactive()) { # First, build the r5r network library(r5r) # Note: This requires a valid r5r network. # Using the sample data included in the r5r package: data_path <- system.file("extdata/poa", package = "r5r") r5r_network <- setup_r5(data_path = data_path) # Launch the application without specifying center and zoom # The map will be automatically centered and zoomed to the network's extent r5r_gui(r5r_network) # Launch with a specific departure date with auto-zoom and center r5r_gui(r5r_network, departure_date = as.Date("2019-05-13")) # Launch with specific transport modes r5r_gui(r5r_network, mode = c("WALK", "BUS")) # Manually define map center and zoom map_center <- c(-51.22, -30.05) map_zoom <- 11 r5r_gui(r5r_network, center = map_center, zoom = map_zoom) # Compare two networks # Note: For this example, we use the same network object twice. # In a real scenario, you would use two different networks (e.g. current vs future). r5r_gui(list("Baseline" = r5r_network, "Scenario A" = r5r_network)) }if (interactive()) { # First, build the r5r network library(r5r) # Note: This requires a valid r5r network. # Using the sample data included in the r5r package: data_path <- system.file("extdata/poa", package = "r5r") r5r_network <- setup_r5(data_path = data_path) # Launch the application without specifying center and zoom # The map will be automatically centered and zoomed to the network's extent r5r_gui(r5r_network) # Launch with a specific departure date with auto-zoom and center r5r_gui(r5r_network, departure_date = as.Date("2019-05-13")) # Launch with specific transport modes r5r_gui(r5r_network, mode = c("WALK", "BUS")) # Manually define map center and zoom map_center <- c(-51.22, -30.05) map_zoom <- 11 r5r_gui(r5r_network, center = map_center, zoom = map_zoom) # Compare two networks # Note: For this example, we use the same network object twice. # In a real scenario, you would use two different networks (e.g. current vs future). r5r_gui(list("Baseline" = r5r_network, "Scenario A" = r5r_network)) }
A simple wrapper function to launch the r5rgui Shiny application using
the sample Porto Alegre dataset included with the r5r package.
This function is designed for ease of use and demonstration purposes. It
automatically handles the setup of the r5r_network object and provides
default map settings (center and zoom) appropriate for the sample data.
r5r_gui_demo(mode = c("WALK", "TRANSIT"))r5r_gui_demo(mode = c("WALK", "TRANSIT"))
mode |
A character vector specifying the initial transport modes. Defaults to |
The function first locates the sample data within the r5r package, then
calls r5r::setup_r5() to build the routing core. Finally, it launches
the Shiny app by calling r5r_gui() with these pre-configured objects.
Please note that r5r may need to download the sample data on first use,
which requires an internet connection.
This function does not return a value; it launches a Shiny application.
if (interactive()) { # To run the demo application, simply call the function: r5r_gui_demo() # Run with specific transport modes r5r_gui_demo(mode = c("WALK", "BUS")) }if (interactive()) { # To run the demo application, simply call the function: r5r_gui_demo() # Run with specific transport modes r5r_gui_demo(mode = c("WALK", "BUS")) }