We’ve finally arrived at creating our first maps based on the data we imported and cleaned in the previous sessions. Let’s start super simple.

Yet, remember that we had to fix geometries with sf::st_make_valid() during the session? tmap has a global option to do that automatically for you. Now that’s nice, right? Run it first in order to conduct the exercises.

tmap::tmap_options(check.and.fix = TRUE)

1

Again, import the corona_cologne dataset. Create a map with only the outline of Cologne is visible.
Remember the different tm_XYZ() functions for polygon data.

2

Now, create a map where the district’s borders are visible. If your adventurous you could play a bit with different colors using the col argument.
The col argument is within the function call for the polygons.

3

Visualize some information about Covid-19 cases within the districts using the number of cases in the last seven days per 100,000 inhabitants (a_7_100.)
You now have to define the column name within the function call for the polygons.

4

Alternate the map by changing the color palette to our one suitable for color vision deficiencies.
There is not only viridis. You can also try magma, plasma, inferno, and cividis. Generally, it is worthwhile to run the function tmaptools::palette_explorer() to have a look at different color palettes.

5

Add a legend title and place the legend outside of the map/frame to the left.
To figure out how to define the location of the map refer to ?tm_layout

6

Add a compass and a scale bar to the map. Place the compass to the top right corner and the scale bar to the bottom left.
You could also try playing with some of the styles for the compass (?tm_compass)

7

Finally, import the hospitals_cologne data and plot them as points onto the map. Chose a proper color.
You could also try playing with some of the styles for the compass (?tm_compass)