mapsf 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).
sf objects on
mf_map() is the main function of mapsf, it displays map layers on a georeferenced plot. It has three main arguments:
var, the name(s) of a variable(s) to map and
type, the map layer type.
Example of choropleth map:
Here are examples of each type of map:
Along with the cartographic functions, some other functions are dedicated to layout design (e.g. legends, scale bar, north arrow, title, credits…).
mf_theme() defines a map theme. It sets the margins of the figure, a background color, a foreground color and some title parameters. A set of theme is included in the package and it is possible to create custom ones.
Here are the built-in themes:
One can create an inset map with
mf_inset_on(x = "worldmap") and
mf_worldmap() a world scale situation map is created:
Inset are not limited to maps, in this example we have created an inset to display a « histogram-legend ».
mf_init() plots an invisible layer with the extent of a spatial object.
Note the use of
expandBB to expand the map space on one (or several) side of the figure. This argument can be useful to save some space to display legends or insets.
mf_init() function can be used to export maps in raster (PNG) or vector formats (SVG). The size of the exported map will fit the height/width ratio of a spatial object (
x). It allows to produce well fitted figures without excessive margins.
mapsf is, mostly, compatible with the pipe syntax (
magrittr, and likely the future
The development of
mapsf happens on GitHub. This project uses conventional commits that force the creation of an explicit commit history.
mapsf will not be enriched by « exotic » map representations (waffle maps, dicontinuities, map tiles…). If these mapping methods are needed, they will be developped in one or several complementary packages (e.g. maptiles for downloading and displaying map tiles).
cartography was created in 2015. It was based on
rgeos. V2.0.0 introduced
sf compatibility and internally switched to
sf functions and objects. But the general API was not significatly modified.
Some initial choices (camelCase, ultra-verbose function and argument names) were not the most inspired. This, plus the need to ensure a correct minimum backward compatibility (132k downloads for
cartography through the RStudio CRAN), tend to hinder the development of new feature.
mapsf is the successor of
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.
mapsf vignette to migrate from
I would like to thank Hugues Pecout for its beautiful hex logo and its always relevant feedback on the user-friendliness of the package website, Diego Hernangómez for its work on the design of package website, and of course authors and contributors of the
sf package and the essential