In this exercise, we are going to re-use the results from the previous one. If you don’t have them available, fire up the code below.

1

Say, we want to draw a compass as a simple arrow on a map. What do you think would be a good position for a compass?
Think outside the box :-)

Look at this code to create compass coordinates (for an arrow):

gesis_cologne_compass_data <- 
  (gesis_bbox + c(?, ?, ?, ?)) %>% 
  sf::st_as_sfc() %>%
  sf::st_sf()

2

If we were to draw the compass arrow in the upper right corner, what do you think would be some reasonable offset values for the bounding box? The values define the arrow’s start and endpoint; thus, they have to be adjusted to be vertical in space.
There is no right or wrong as we have to test them in the next step. So this is a mean question. But remember that the bounding box is 1000 meters on each side and that the bounding box values are ordered this way: minimum x-value, minimum y-value, maximum x-value, and maximum y-value.

Admittedly, drawing custom elements is a matter of fiddling around. We want to draw an arrow, and we didn’t have this before. Here’s a way to use our compass data and add it to an existing ggplot. Please feel free to adapt it to your liking.

geom_segment(
  data = 
    gesis_cologne_compass_data %>% 
    rotate_data() %>% 
    sf::st_bbox() %>% 
    {data.frame(xmin = .$xmin, xmax = .$xmax, ymin = .$ymin, ymax = .$ymax)},
  aes(x = xmin, y = ymin, xend = xmax, yend = ymax),
  size = 1.2,
  arrow = arrow(length = unit(0.2, "cm"), type = "closed")
)

3

Recreate the unrotated and the rotated map from Exercise 1_4_1 and add the pre-defined geom_segment(). Do your offset values from exercise “2” look nice? Adapt them, if not.
There’s a lot of stuff happening on the map. Think about applying the ggsn::blank() function to remove all the clutter. Also, you don’t need the rotate_data() function for the unrotated map, right?