High-Performance Interactive Mapping

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 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, by the MapLibre Organization (2020) < https://github.com/MapLibre>. 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 toro website

R-CMD-check CRAN status

Overview

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:

  • eDNA and biodiversity monitoring: map sampling sites, species detections, read counts, and habitat layers to spot spatial biodiversity patterns and guide future field sampling.
  • Ecology and conservation: visualise telemetry tracks, protected-area boundaries, invasive species records, or restoration sites with interactive layers and clustering.
  • Environmental modelling: explore spatial model outputs such as pollution gradients, flood risk, fire exposure, climate surfaces, or watershed indicators.
  • Mathematical and statistical teaching: demonstrate spatial clustering, interpolation, coordinate systems, distance metrics, and animated trajectories using live, interactive maps.
  • Geospatial data analysis: inspect large coordinate-based datasets, compare map tile contexts, toggle layers, and export reproducible visual outputs for reports or dashboards.

Installation

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.

Getting started

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")

Where to next?

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.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("toro")

0.2.0 by Uli Muellner, 13 days ago


https://epi-interactive-ltd.github.io/toro/, https://github.com/Epi-interactive-Ltd/toro/


Report a bug at https://github.com/Epi-interactive-Ltd/toro/issues


Browse source code at https://github.com/cran/toro


Authors: Epi , NZ [aut, cph, fnd] (The package was designed and developed by Epi (<https://www.epi.group/>)) , Uli Muellner [cre] , Poppy Pakinui [ctb] , Kiel Hards [ctb] , Nick Snellgrove [ctb] , Jocelyn Qian [ctb] , Petra Muellner [ctb] , MapLibre contributors [cph] (MapLibre GL JS library) , Turf contributors [cph] (turf plugin) , Mapbox contributors [cph] (mapbox-gl-draw plugin)


Documentation:   PDF Manual  


AGPL (>= 3) license


Imports base64enc, geojsonsf, htmlwidgets, jsonlite, sf, shiny

Suggests devtools, dplyr, knitr, mapview, rmarkdown, spData, testthat, usethis, webshot, webshot2


See at CRAN