+
Skip to content

r-tmap/tmap.mapgl

Repository files navigation

“mapbox” and “maplibre” modes in tmap

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

tmap mapbox mode

tmap mapbox mode

maplibre

tmap_mode("maplibre")

tm_shape(World) + 
  tm_polygons("well_being",
    fill.scale = tm_scale_continuous(values = "pu_gn"))

tmap maplibre mode

tmap maplibre mode

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载