
Interactive spatial visualisations are a cornerstone for exploring and communicating complexity, and are commonly embedded into reports or interactive dashboards. However, as the amount of data grows, so do the demands on functionality, especially for technical and scientific data. To bridge this gap and create a mapping package that is high performing, a modern approach is needed that draws from best software engineering practices. toro provides R bindings to MapLibre GL JS, an open-source JavaScript/TypeScript library for rendering interactive maps in the browser, built from the ground up for responsiveness and scale. This connection allows users to create interactive maps that can easily be integrated into both Quarto and the R Shiny dashboard framework. toro thereby enables spatial visualisation and exploration of data that might otherwise be too limited, too slow, or too hard to scale using more traditional interactive mapping tools such as leaflet.
toro was created by Epi.
If you have any comments, questions, or suggestions, please contact us.
Uses cases for toro: As a general purpose library with a focus on interactivity and performance, toro maps are ideal for complex data that may be used in web apps, teaching, interactive reports and presentations. Use cases for toro include, but are not limited to:
Install from CRAN:
install.packages("toro")Or, install the development version from GitHub:
pak::pak("Epi-interactive-Ltd/toro")Once installed, this package can be used in the R console and within Shiny applications or Quarto reports.
The central function of the package is the map function,
this creates a htmlwidget for interactive use with a base
world map layer:
library(toro)
map()
Further arguments can be passed to customise the styling of the map:
map(
style = "streets",
center = c(174, -41),
zoom = 2
)
From there, tidyverse-style pipelines are used to add various data, via geospatial simple-features objects, to the map in layers:
# A single point made via the sf package
data <- sf::st_as_sf(
data.frame(lat = c(-41.306579555227245), long = c(174.82263228933076)),
coords = c("long", "lat"),
crs = 4326
)
map(
style = "streets",
center = c(174, -41),
zoom = 5
) |>
add_symbol_layer(
id = "marker-layer",
source = data
)
As a htmlwidget, all toro maps are supported in
any supporting framework, including Shiny, Quarto and more. Maps can
further be exported to standalone html files (for further interactive
use), or static images can be saved:
map(
style = "streets",
center = c(174, -41),
zoom = 2
) |>
add_symbol_layer(
id = "marker-layer",
source = data
) |>
export_map_image("map.png")The layers vignette, details the different kinds of data that can be plotted and their different configurations. For styling the underlying base map, please see the map tiles vignette. Users interested in integration with Shiny apps should see the integration with Shiny vignette, which responsive and dynamic visualisation in dashboard contexts.