SkillAgentSearch skills...

Tmap.mapgl

tmap extension featuring two new modes: 'mapbox' and 'maplibre'

Install / Use

/learn @r-tmap/Tmap.mapgl
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

“mapbox” and “maplibre” modes in tmap <img src="man/figures/logo.png" align="right" height="139" alt="" />

tmap is a R package for visualizing spatial data. This package, tmap.mapgl is an extension which features two new modes: "mapbox" and "maplibre".

Installation

This package is in development so the development version of both tmap and tmap.mapgl are required.

tmap

# install.packages("remotes")
remotes::install_github("r-tmap/tmap")

# install.packages("pak")
pak::pak("r-tmap/tmap")

# Or from r-universe
install.packages("tmap", repos = c("https://r-tmap.r-universe.dev", "https://cloud.r-project.org"))

For Linux and macOS users who are new to working with spatial data in R, this may fail since additional (non-R) libraries are required (which are automatically installed for Windows users).

tmap.mapgl

# install.packages("remotes")
remotes::install_github("r-tmap/tmap.mapgl")

# install.packages("pak")
pak::pak("r-tmap/tmap.mapgl")

# Or from r-universe
install.packages("tmap.mapgl", repos = c("https://r-tmap.r-universe.dev", "https://cloud.r-project.org"))

For "mapbox" an API key is required, which is free for personal use.

mapbox API key

  1. Go to Mapbox Access Tokens and follow the instructions
  2. Set the API key as a system environment variable. This can be done by
    1. running usethis::edit_r_environ() which creates/opens a text file named .Renviron in your user’s home folder
    2. adding the line MAPBOX_PUBLIC_TOKEN="abc123", where abc123 should be replaced by your API key obtained in step 1.

Example

mapbox

library(tmap)
library(tmap.mapgl)

tmap_mode("mapbox")

tm_shape(World) + 
  tm_polygons("well_being",
    fill.scale = tm_scale_continuous(values = "pu_gn"))
<figure> <img src="https://r-tmap.github.io/tmap.mapgl/reference/figures/mapbox_well_being.jpg" alt="tmap mapbox mode" /> <figcaption aria-hidden="true">tmap mapbox mode</figcaption> </figure>

maplibre

tmap_mode("maplibre")

tm_shape(World) + 
  tm_polygons("well_being",
    fill.scale = tm_scale_continuous(values = "pu_gn"))
<figure> <img src="https://r-tmap.github.io/tmap.mapgl/reference/figures/maplibre_well_being.jpg" alt="tmap maplibre mode" /> <figcaption aria-hidden="true">tmap maplibre mode</figcaption> </figure>

Related Skills

View on GitHub
GitHub Stars17
CategoryDevelopment
Updated19d ago
Forks1

Languages

R

Security Score

90/100

Audited on Mar 18, 2026

No findings