Mapsf

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Thematic maps with mapsf : : CHEAT SHEET

Create and integrate thematic maps


in your workflow.
Symbology Map Layout
The x argument should be an sf object. Along with cartographic functions, other
Input geometries can be polygons, lines functions are dedicated to customize
Base map or points. the layout design.
Import library
library(mapsf)
Choropleth (ratios)
mf_map(x = mtq, type = "choro",
var = "var", method = "quantile") 1 7
9 10
Export Maps
Import the sample data set
mtq <- mf_get_mtq()
mf_export() exports maps in PNG or
Typology (categories) SVG formats.
Initiate a base map centered on a specific extent mf_map(x = mtq, type = "typo", var = "var") 2
mf_map(x = mtq, col = "orange", The exported map width/height ratio will match the
border = "white") 6 one of a spatial object.
3
8
Plot symbogy Proportional Symbols (stocks) 5 Additionally, mf_export() can be used to set a
mf_map(x = mtq, type = "prop", var = "POP", mf_map(x = mtq, type = "prop", var = "var", 11 theme, to extend the map space on one or several
leg_title = "Population", add = TRUE) 4
inches = 0.1, symbol = "circle") side of the figure, or to center a map on a specific area.
12
Complete layout (credits, title, north, arrow, scale bar)
Simple export (PNG)
mf_layout(title = "Martinique", Graduated Symbols (stocks) 1 Set a map theme (figure margins, colors, title options...) mf_export(x = mtq, width = 500,
credits = "Sources: IGN, 2018") mf_map(x = mtq, type = "grad", var = "var", mf_theme(bg = "white", tab = TRUE, filename = "my_export.png")
pch = 24) mar = c(0,0,0,0), pos = "left") mf_map(x = mtq, add = TRUE)
Builtin themes are available : default, ink, dark, agolalight, candy, dev.off()
darkula, iceberg, green, nevermind, jsk or barcelona.
Symbols (categories)
mf_map(x = mtq, type = "symb", var = "var", Export with a theme (SVG)
2 Init a map centered on a specific area mf_export(x = mtq, width = 5, export = "svg",
pch = c(21:23))
mf_init(x = mtq[30, ]) filename = "my_export.svg",
mf_map(x = mtq, col = "orange", theme = "nevermind")
border = "white", add = TRUE) mf_map(x = mtq, add = TRUE)
Choropleth proportional symbols (stocks - ratios)
mf_map(x = mtq, type = "prop_choro", dev.off()
3 Import external image for background
var = c("var1", "var2"))
mf_background(filename = "img/sea.jpg") Extra space on the figure (bottom, left, top, right)
mf_export(x = mtq, width = 500,
4 Create a shadow effect
Colorized proportional symbols (stocks - categ.) filename = "my_export.png",
mf_map(x = mtq, type = "prop_typo", mf_shadow(...) expandBB = c(0,0.6,0,0)
var = c("var1", "var2")) mf_map(x = mtq, add = TRUE)
5 Create a custom inset +60%
dev.off()
mf_inset_on(x = mtq, pos = "bottomleft")
Chropleth symbols (ratios - categories) mf_map(...) Export a map centered on a specific area
mf_map(x = mtq, type = "symb_choro", mf_inset_off() mf_export(x = mtq[30,], height = 600,
var = c("var1", "var2"),
filename = "my_export.png")
pch = c(21:23)) 6 Create a world inset mf_map(x = mtq, add = TRUE)
mf_inset_on(x = "worldmap", pos = "right") dev.off()
Raster mf_worldmap(mtq)
mf_raster(x = raster) mf_inset_off()

7 Plot title
mf_title("A beautiful beach")
Further documentation
8 Plot labels
Legends mf_label(...) Vignettes on mapsf website: riatelab.github.io/mapsf
> Get started
9 Plot annotation (in specific locations)

Colors
Default legends are plotted along maps. > How to Use Themes
mf_annotation(...)
Customization parameters are available with > How to Export Maps
mf_legend() > How to Create Inset Maps
10 North arrow
mapsf can use color palettes from hcl.colors(). 15
mf_arrow(...)
> How to Create Faceted Maps
mf_get_pal() is useful to create well-balanced 50 A A
10
> How to Use a Custom Font Family
40
asymetric diverging palettes 30 B 4
11 Scale (in km)
B
20 mf_scale(...)
C 3
10

No Data D C 2 12 Credits
mf_get_pal(n = c(7, 2), pal = c("Burg", "Mint")) 1 mf_credits(...) mapsf - CRAN.R-project.org/package=mapsf - CC BY SA Ronan Ysebaert - 2021-11

You might also like