Tmap.mapgl
tmap extension featuring two new modes: 'mapbox' and 'maplibre'
Install / Use
/learn @r-tmap/Tmap.mapglREADME
“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
- Go to Mapbox Access Tokens and follow the instructions
- Set the API key as a system environment variable. This can be done
by
- running
usethis::edit_r_environ()which creates/opens a text file named.Renvironin your user’s home folder - adding the line
MAPBOX_PUBLIC_TOKEN="abc123", where abc123 should be replaced by your API key obtained in step 1.
- running
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
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
