-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.Rmd
63 lines (46 loc) · 3.45 KB
/
index.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
---
title: "Making thematic maps with R"
author: "Maarten Hermans"
---
This online walkthrough accompanies a [3h "show-and-tell" workshop](https://mhermans.net/talk/2019-02-11-r-thematic-maps/) on **making thematic (choropleth) maps in R**.
The worked examples demonistrate the quickest routes for getting your data in R and on a map, with a focus on showing how spatial data can be integrated in a familiar [tidyverse data-analysis workflow](https://www.tidyverse.org/).
The examples demonstrate mainly static maps, but interactive thematic maps are included as well. R packages demonistrated are primary
* [sf](https://r-spatial.github.io/sf/) and [tmap](https://github.com/mtennekes/tmap#tmap-thematic-maps-in-r), together with
* [leaflet](https://rstudio.github.io/leaflet/), [ggplot](https://ggplot2.tidyverse.org/) and
* supporting packages such as [BelgiumMaps.StatBel](http://www.bnosac.be/index.php/blog/55-belgiummaps-statbel-r-package-with-administrative-boundaries-of-belgium) and [eurostat](https://ropengov.github.io/eurostat/index.html).
Intended audience is basic R users (or those interested in seeing what R can do), who wish integrate spatial data into their "regular" (exploratory) data-analysis workflow, or who need a quick map. More advanced [GIS](https://en.wikipedia.org/wiki/Geographic_information_system)-topics such as projection fall outside of the scope.
The material and examples are structured along the basic steps you generally take when making thematic maps:
0. [Motivating examples](00_start_examples.html) of static and interactive thematic maps.
1. [Get an appropriate blank map](01_get_maps.html) to visualise your data on, e.g. from Belgium, Europe or the world.
2. [Load and add](02_add_data.html) the data-of-interest you wish to visualise.
3. Jointly [manipulate](03_manipulate.html) your spatial and "regular" data.
4. Finally, [plot and tweak your map](04_plot.html). E.g. choosing color palettes, multiple maps, styling, etc.
I like [hearing from you](https://mhermans.net/#contact) if this walkthrough has been useful somehow, if something is not working or can be improved, or if you are interested in a workshop.
# Download the material
You can copy-past the code snippets from the online pages, [download](https://github.com/mhermans/thematic-maps-r/archive/master.zip) (25MB) the entire set of material, or [clone from Github](https://github.com/mhermans/thematic-maps-r).
Opening the file `thematic_maps_with_r.Rproj` in the downloaded folder launches an Rstudio-project, after which you should be able to open, adapt, and run the Rmarkdown notebooks containing the examples (files ending in .Rmd).
# Setup
1. [Download](https://cran.r-project.org/bin/windows/base/) and install R.
2. [Download](https://www.rstudio.com/products/rstudio/download/#download) and install Rstudio.
3. Run commands below to install required R-packages.
```{r, eval=FALSE}
install.packages('rmarkdown')
install.packages('sf')
install.packages('tmap')
install.packages('dplyr')
install.packages('readxl')
install.packages('eurostat')
install.packages('leaflet')
install.packages('haven')
install.packages('mapview')
install.packages('rgdal')
install.packages('tmaptools')
install.packages('countrycode')
install.packages('stringr')
install.packages('readr')
install.packages('ggplot2')
install.packages('htmlwidgets')
install.packages('rworldmap')
install.packages('lubridate')
install.packages("BelgiumMaps.StatBel", repos = "http://www.datatailor.be/rcube", type = "source")
```