• Stars
    star
    398
  • Rank 108,325 (Top 3 %)
  • Language
    R
  • Created over 9 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Thematic Cartography for R

cartography

R-CMD-check Codecov test coverage DOI

Consider mapsf

There are no plans for new features or enhancements in cartography. Basic maintenance and support will continue indefinitely. Existing projects that use cartography can safely continue to use cartography. The mapsf R package is the successor of cartography and it is friendlier, lighter and more robust. See mapsf vignette or this blog post to migrate from cartography to mapsf.

Create and integrate maps in your R workflow!

This package helps to design cartographic representations such as proportional symbols, choropleth, typology, flows or discontinuities maps. It also offers several features that improve the graphic presentation of maps, for instance, map palettes, layout elements (scale, north arrow, title...), labels or legends.

Demo

The following script creates a map of symbols that are proportional to values of a first variable and colored to reflect the classification of a second variable.

library(sf)
library(cartography)
# path to the geopackage file embedded in cartography
path_to_file <- system.file("gpkg/mtq.gpkg", package="cartography")
# import to an sf object
mtq <- st_read(dsn = path_to_file, quiet = TRUE)

########## Draft Map
# Plot the municipalities
plot(st_geometry(mtq))
# Plot symbols with choropleth coloration (population & median income)
propSymbolsChoroLayer(x = mtq, var = "POP", var2 = "MED")
# Add a layout
title(main = "Population & Wealth in Martinique, 2015", 
      sub = "Sources: Insee and IGN - 2018")

########## Final Map
# Set figure margins
opar <- par(mar = c(0,0,1.2,0))
# Plot the municipalities
plot(st_geometry(mtq), col="darkseagreen3", border="darkseagreen4",  
     bg = "lightblue1", lwd = 0.5)
# Plot symbols with choropleth coloration
propSymbolsChoroLayer(x = mtq, var = "POP", inches = 0.4, border = "grey50",
                      lwd = 1, legend.var.pos = "topright", 
                      legend.var.title.txt = "Population",
                      var2 = "MED", method = "equal", nclass = 4, 
                      col = carto.pal(pal1 = "sand.pal", n1 = 4),
                      legend.var2.values.rnd = -2,  legend.var2.pos = "left", 
                      legend.var2.title.txt = "Median Income\n(in euros)") 
# Plot a layout
layoutLayer(title="Population & Wealth in Martinique, 2015", 
            author = "cartography 2.1.3", 
            sources = "Sources: Insee and IGN - 2018", 
            scale = 5, tabtitle = TRUE, frame = FALSE)
# Plot a north arrow
north(pos = "topleft")
# restore graphics parameters
par(opar)

Installation

  • Development version on GitHub
remotes::install_github("riatelab/cartography")
  • Stable version on CRAN
install.packages("cartography")

Alternatives

Community Guidelines

One can contribute to the package through pull requests and report issues or ask questions here.


To cite package cartography in publications use one of these:

More Repositories

1

bertin

A package to draw maps in javascript
JavaScript
304
star
2

osrm

Interface between R and the OpenStreetMap-based routing service OSRM
R
237
star
3

mapsf

Thematic cartography with R
R
224
star
4

magrit

Thematic cartography entirely in the browser ♥
TypeScript
127
star
5

linemap

Create maps made of (ridge) lines
R
116
star
6

maptiles

Download, compose and display map tiles with R
R
97
star
7

tanaka

Tanaka Maps with R
R
78
star
8

geotoolbox

geojson toolbox
JavaScript
59
star
9

geoviz

d3-based javascript library for thematic maps
JavaScript
42
star
10

mapiso

Transformation of regularly spaced grids into contour polygons
R
34
star
11

dicopal.js

Discrete color palettes (hundreds of them!) for JavaScript
TypeScript
32
star
12

SpatialPosition

R package for computing spatial position models
R
31
star
13

potential

An R package to compute the potential model as defined by Stewart (1941).
R
25
star
14

geoverview

Quick geojson overview and summary
JavaScript
25
star
15

bertinR

A wrapper for bertin.js
R
23
star
16

statsbreaks

A javascript package to group the values of a statistical series into classes (discretization)
JavaScript
22
star
17

ReproducibleCartography

ICC 2017 Reproducible Cartography
HTML
18
star
18

mapinsetr

Create map inset
R
17
star
19

fisheye

Transform base maps using log-azimuthal projection
R
15
star
20

maplegend

Create legends for maps and other graphics.
R
12
star
21

flows

Flow selection and analysis
R
11
star
22

go-cart-wasm

Flow-based cartograms (Gastner-Seguy-More 2018 algorithm) for the Web
JavaScript
9
star
23

regioviz

Regioviz - Outil de visualisation et de comparaison régionale 📊 📈
JavaScript
8
star
24

intro_sf

Faire des cartes avec R - Introduction au package sf
8
star
25

MTA

Multiscalar Territorial Analysis
R
7
star
26

anfdataviz

HTML
6
star
27

gepaf

Encode and decode the Google Encoded Polyline Algorithm Format
R
6
star
28

cartostats

Reproducible Cartography
HTML
4
star
29

geocountries

A tool to get ISO codes and geometries from country names
JavaScript
3
star
30

basemaps

2
star
31

map-templates

R programmes to build map templates for Magrit (with boxes for overseas and outermost territories), with data.
R
2
star
32

MAGRIT-formations

Supports pour les formations en cartographie avec Magrit
HTML
2
star
33

rgvzall

Tool for regional comparison and data visualisation with data for France, Europe and Tunisia
JavaScript
2
star
34

world

country base map
1
star
35

MDM

non
HTML
1
star
36

cartographie-reproductible

Cartographie Reproductible
JavaScript
1
star
37

regiovizlab

Landing page for Regioviz (RIATE version)
HTML
1
star
38

anticartogram

HTML
1
star
39

linearcorrelation

Statistical operators for bi-variate analysis
JavaScript
1
star