SkillAgentSearch skills...

Tmap

R package for thematic maps

Install / Use

/learn @r-tmap/Tmap
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

tmap: thematic maps in R <img src="man/figures/logo.png" align="right" height="139" alt="" />

<!-- badges: start -->

R-CMD-check Codecov test
coverage CRAN CRAN
checks Downloads License r-universe

<!-- badges: end -->

tmap is an R package for drawing thematic maps. The API is based on A Layered Grammar of Graphics and resembles the syntax of ggplot2, a popular R-library for drawing charts.

Installation

Installation of tmap is straightforward:

install.packages("tmap")

In case it fails, please check the dependencies below.

Development version

The development version can be installed from the GitHub repository using one of the following functions:

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

Dependencies

tmap depend on other R packages, which will automatically be installed along. However, two packages sf and s2 have additional system requirements: for Windows users, these are also installed along. For Linux and MacOS users, these additional libraries may need to be installed manually.

Instructions for the libraries GEOS, GDAL and PROJ (required by sf): see the installation instructions of terra which requires the same libraries: MacOS and Linux

Instructions for the libraries Abseil and OpenSSL (required by s2): see the installation instructions.

Getting started

Plot a World map of the happy planet index (HPI) per country. The object World is an example spatial data (sf) object that is contained in tmap:

tm_shape(World) +
    tm_polygons(fill = "HPI")
<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />

This map can be enhanced in several ways. For instance:

tm_shape(World, crs = "+proj=robin") +
    tm_polygons(fill = "HPI",
                fill.scale = tm_scale_continuous(values = "matplotlib.rd_yl_bu"),
                fill.legend = tm_legend(title = "Happy Planet Index",
                                        orientation = "landscape", 
                                        frame = FALSE)
                )
<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />

Online tmap course

3-6 June, organized jointly by PRStats and Instats

Additional Resources for Learning tmap

For more in-depth learning on the tmap package, refer to the following resources:

These resources provide a solid foundation for working with tmap in R.

View on GitHub
GitHub Stars900
CategoryDevelopment
Updated12d ago
Forks124

Languages

R

Security Score

100/100

Audited on Mar 18, 2026

No findings