https://github.com/riatelab/mapsf
Thematic cartography with R
https://github.com/riatelab/mapsf
cartography map r r-package rstats spatial spatial-analysis
Last synced: 3 months ago
JSON representation
Thematic cartography with R
- Host: GitHub
- URL: https://github.com/riatelab/mapsf
- Owner: riatelab
- License: gpl-3.0
- Created: 2020-06-25T13:28:50.000Z (about 5 years ago)
- Default Branch: dev
- Last Pushed: 2025-03-25T16:58:46.000Z (4 months ago)
- Last Synced: 2025-04-02T04:07:23.992Z (3 months ago)
- Topics: cartography, map, r, r-package, rstats, spatial, spatial-analysis
- Language: R
- Homepage: https://riatelab.github.io/mapsf/
- Size: 132 MB
- Stars: 229
- Watchers: 11
- Forks: 25
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Citation: CITATION.cff
- Codemeta: codemeta.json
Awesome Lists containing this project
- awesome-flow-visualization - mapsf - Successor to cartography (Tools (by Language/ parent software) / R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
fig.width = 5, fig.height = 6,
dev = "png"
# out.width = "100%"
)
```# mapsf
[](https://cran.r-project.org/package=mapsf)
[](https://github.com/riatelab/mapsf/actions/workflows/R-CMD-check.yaml)
[](https://cran.r-project.org/package=mapsf)
[](https://app.codecov.io/gh/riatelab/mapsf?branch=master)
[](https://CRAN.R-project.org/package=mapsf)
[](https://www.bestpractices.dev/projects/8704)
[](https://www.repostatus.org/#active)**Create thematic maps and integrate them into your R workflow.**
This package helps you design different cartographic representations such as
proportional symbols, choropleths, or typology maps.
It also provides several functions for displaying layout elements
that enhance the graphical presentation of maps
(e.g., scale bar, north arrow, title, labels).
`mapsf` maps `sf` objects on `base` graphics. & [Web Site](https://riatelab.github.io/mapsf/)](man/figures/mapsf_cheatsheet.png)
## Installation
You can install the released version of `mapsf`
from [CRAN](https://cran.r-project.org/package=mapsf) with:``` r
install.packages("mapsf")
```Alternatively, you can install the development version of `mapsf`
from GitHub (**dev** branch) with:``` r
remotes::install_github("riatelab/mapsf", ref = "dev")
```## Usage
This is a basic example which shows how to create a map with `mapsf`.
The main `mapsf` function is `mf_map()`.```{r example1, fig.width = 4, fig.height = 5}
library(mapsf)
# Import the sample dataset
mtq <- mf_get_mtq()
# Plot the base map
mf_map(x = mtq)
# Plot proportional symbols
mf_map(x = mtq, var = "POP", type = "prop", leg_pos = "topright")
# Plot a map layout
mf_layout(
title = "Population in Martinique",
credits = "T. Giraud; Sources: INSEE & IGN, 2018"
)
```A more detailed example:
```{r example2, results="hide", eval = TRUE, fig.width=6, fig.height=5.87}
# A map with a theme and extra margins
mf_theme("sol_dark")
# Plot a choropleth map
mf_map(
x = mtq, var = "MED", type = "choro",
breaks = "quantile", nbreaks = 6,
leg_title = "Median Income\n(euros)", leg_val_rnd = -2,
expandBB = c(0, 0, 0, .3)
)
# Start an inset map
mf_inset_on(x = "worldmap", pos = "right")
# Plot mtq position on a worldmap
mf_worldmap(mtq, col = "#0E3F5C")
# Close the inset
mf_inset_off()
# Plot a title
mf_title("Wealth in Martinique, 2015")
# Plot credits
mf_credits("T. Giraud\nSources: INSEE & IGN, 2018")
# Plot a scale bar
mf_scale(size = 5)
# Plot a north arrow
mf_arrow("topleft")
```## Alternatives
- [tmap](https://github.com/r-tmap/tmap)
- [ggplot2](https://github.com/tidyverse/ggplot2) + [ggspatial](https://github.com/paleolimbot/ggspatial)## Community Guidelines
One can contribute to the package through [pull requests](https://github.com/riatelab/mapsf/pulls) and report issues or ask questions [here](https://github.com/riatelab/mapsf/issues). See the [CONTRIBUTING.md](https://github.com/riatelab/mapsf/blob/master/CONTRIBUTING.md) file for detailed instructions on how to contribute.
This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.3/) and [semantic versioning](https://semver.org/).