Skip to content

r-tmap/tmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8ca4721 · Mar 25, 2025
Oct 23, 2024
Mar 25, 2025
Jan 7, 2025
Dec 29, 2024
Sep 19, 2023
Feb 28, 2025
Jan 14, 2025
Mar 25, 2025
Sep 20, 2023
Dec 26, 2024
Dec 26, 2024
Feb 7, 2025
Jan 15, 2025
Dec 18, 2024
Jan 6, 2025
Feb 24, 2025
Nov 25, 2013
Mar 3, 2025
Feb 24, 2025
Feb 27, 2025
Feb 27, 2025
Feb 28, 2025
Sep 14, 2023
Jan 27, 2025
Dec 20, 2024

Repository files navigation

tmap: thematic maps in R

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

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 (version 4) is straightforward:

install.packages("tmap")

The old version of tmap (version 3) is available in the CRAN archive, but we recommend moving to the new version 4.

Development version

The development version can be installed from the GitHub repository using remotes and pak packages or from the R-universe repository.

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

Windows No additional installation required.

Linux (Ubuntu) See https://geocompx.org/post/2020/installing-r-spatial-packages-linux/. Please address installation issues in this issue.

macOS See https://www.kyngchaos.com/. Please address installation issues in this issue.

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

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

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.