forked from spatialanalysis/workshop-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-tmap-animation.Rmd
71 lines (49 loc) · 2.16 KB
/
06-tmap-animation.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
# Custom and Animated Maps
## Learning Objectives
- Use `urban_agglomerations` and `world` data from the `spData` package
- Make the same map in `ggplot2` and `tmap`
- Make an animated map and save it
## Functions Learned
- `tm_shape`
- `tm_polygons`
- `tm_dots`
- `tm_facets`
- `tmap_animation`
## Interactive Tutorial
```{block type="rmdinfo"}
This workshop's R Markdown can be found [here](https://github.com/spatialanalysis/workshop-scripts/blob/master/gis-visualization/winter-2019/doc/06-custom-maps.Rmd).
```
## Challenges
This workshop uses an [example]() from Geocomputation with R, developed by Robin Lovelace. The original script can be found [online](https://raw.githubusercontent.com/Robinlovelace/geocompr/master/code/08-urban-animation.R).
```{block type="rmdwarning"}
If you get the following error, make sure the `magick` package is installed with `install.packages("magick")`, and that ImageMagick itself is installed:
>Error in tmap::tmap_animation(tm, filename = "doc/city-pop.gif") :
> Could not find ImageMagick. Make sure it is installed and included in the systems PATH
```
```{block type="learncheck"}
**Challenge**
```
1. Look at the `urban_agglomerations` and the `world` data. What type of spatial data is each (point, line, polygon)? How many observations are in each dataset?
2. What projection is each in?
3. Make a ggplot2 map of both datasets
```{block type="learncheck"}
```
```{block type="learncheck"}
**Challenge**
```
3. Make a tmap map of `urban_agglomerations`.
```{block type="learncheck"}
```
```{block type="learncheck"}
**Challenge**
```
4. Change the color of the points to one of your choosing.
```{block type="learncheck"}
```
```{block type="rmdinfo"}
Luc Anselin has written a more in-depth tutorial for tmap, which you can find and go through [here](https://spatialanalysis.github.io/tutorials/), under Introduction to Spatial Data Science > Basic Mapping.
```
## Links
The links in this workshop:
- Geocomputation with R - Chapter 8 talks about making maps with `tmap`: https://geocompr.robinlovelace.net/adv-map.html
- Getting started with `tmap` vignette: https://cran.r-project.org/web/packages/tmap/vignettes/tmap-getstarted.html