We’ve finally arrived at creating our first maps based on the data we imported and cleaned in the previous sessions. The focus of this first session lies on the package tmap to create maps.
Let’s start super simple. Import our enhanced district data. Create a map with only the outline of Germany and one where the districts’ borders are visible. Chose a color of your choice for both maps.
In a second step, we want to visualize some information on the German districts contained in the attribute table. Choose the column cases_per_100k and create a map of Covid-19 cases per 100,000 inhabitants in Germany. Alternate the map by:
Assign your map to an object called covid_map.
Check the head() of your shapefile. You might need to rename some of the columns or use the correct names: cases_per_100k (abbreviated: cs__100).
Combine following options with a plus sign:
tm_fill(col = "", title = "", palette = "") +tm_layout(title = "", title.color = "") +tm_legend(legend.outside = T/N, legend.outside.position = "")If you run colors(), R returns the names of all built-in colors.
To assign your map to an object, use the arrow <-.