-
Notifications
You must be signed in to change notification settings - Fork 24
/
README.Rmd
175 lines (130 loc) · 5.82 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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 <img src="man/figures/logo.png" align="right" width="120"/>
<!-- badges: start -->
[![CRAN](https://www.r-pkg.org/badges/version-ago/mapsf)](https://cran.r-project.org/package=mapsf)
[![R-CMD-check](https://github.com/riatelab/mapsf/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/riatelab/mapsf/actions/workflows/R-CMD-check.yaml)
[![downloads](https://cranlogs.r-pkg.org/badges/mapsf?color=brightgreen)](https://cran.r-project.org/package=mapsf)
[![Codecov test coverage](https://codecov.io/gh/riatelab/mapsf/branch/master/graph/badge.svg)](https://app.codecov.io/gh/riatelab/mapsf?branch=master)
[![status](https://tinyverse.netlify.app/badge/mapsf)](https://CRAN.R-project.org/package=mapsf)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8704/badge)](https://www.bestpractices.dev/projects/8704)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
<!-- badges: end -->
Create and integrate thematic maps in your R workflow. This package helps to
design various cartographic representations such as proportional
symbols, choropleth or typology maps. It also offers several functions to
display layout elements that improve the graphic presentation of maps
(e.g. scale bar, north arrow, title, labels). `mapsf` maps `sf` objects on
`base` graphics.
## 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 example3, results=FALSE, eval = FALSE}
# Export a map with a theme and extra margins
mf_theme("green")
mf_export(
x = mtq, filename = "mtq.png",
width = 600, res = 120,
expandBB = c(0, 0, 0, .3)
)
# Plot a shadow
mf_shadow(mtq, col = "grey10", add = TRUE)
# Plot a choropleth map
mf_map(
x = mtq, var = "MED", type = "choro",
pal = "Dark Mint",
breaks = "quantile",
nbreaks = 6,
leg_title = "Median Income\n(euros)",
leg_val_rnd = -2,
add = TRUE
)
# 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")
dev.off()
```
<img src='man/figures/mtq.png'/>
## Resources
<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<tbody>
<tr class="odd">
<td style="text-align: center;">
<p><a href="https://raw.githubusercontent.com/riatelab/mapsf/master/vignettes/web_only/img/mapsf_cheatsheet.pdf"><img src="man/figures/mapsf_cheatsheet.png"/></a></p>
<p><a href="https://raw.githubusercontent.com/riatelab/mapsf/master/vignettes/web_only/img/mapsf_cheatsheet.pdf">Cheat Sheet</a></p>
</td>
<td style="text-align: center;">
<p><a href="https://riatelab.github.io/mapsf/"><img src="man/figures/website.png" /></a></p>
<p><a href="https://riatelab.github.io/mapsf/">Website</a></p>
</td>
</tr>
</tbody>
</table>
- `mapsf`, a New Package for Thematic Mapping - useR 2021! [Video](https://youtu.be/8PMF7cBBH7k?t=2621) & [Slides](https://rcarto.github.io/user2021/) - FOSS4G 2021 [Video](https://www.youtube.com/watch?v=dBNp0bzD454) & [Slides](https://rcarto.github.io/foss4g2021/) (EN)
- Créer des cartes reproductibles avec `mapsf` - Les lundis de l'Ined - [Slides](https://rcarto.github.io/ined2021/) (FR)
## Background
`mapsf` is the successor of [`cartography`](https://github.com/riatelab/cartography).
There are no plans for new features or enhancements in `cartography`, but basic maintenance and support will continue indefinitely.
Existing projects that use `cartography` can safely continue to use `cartography`.
New projects should use `mapsf` because it is friendlier, lighter and more robust.
See [`mapsf` vignette](https://riatelab.github.io/mapsf/articles/mapsf.html#symbology) to migrate from `cartography` to `mapsf`.
## Alternatives
- [cartography](https://github.com/riatelab/cartography) (*superseded by `mapsf`*)
- [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/).