Chapter 6 Custom and Animated Maps
6.1 Learning Objectives
- Use
urban_agglomerations
andworld
data from thespData
package - Make the same map in
ggplot2
andtmap
- Make an animated map and save it
6.2 Functions Learned
tm_shape
tm_polygons
tm_dots
tm_facets
tmap_animation
6.3 Interactive Tutorial
This workshop’s R Markdown can be found here.
6.4 Challenges
This workshop uses an example from Geocomputation with R, developed by Robin Lovelace. The original script can be found online.
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
Challenge
Look at the
urban_agglomerations
and theworld
data. What type of spatial data is each (point, line, polygon)? How many observations are in each dataset?What projection is each in?
Make a ggplot2 map of both datasets
Challenge
- Make a tmap map of
urban_agglomerations
.
Challenge
- Change the color of the points to one of your choosing.
Luc Anselin has written a more in-depth tutorial for tmap, which you can find and go through here, under Introduction to Spatial Data Science > Basic Mapping.
6.5 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