Spatial Visualization or Maps

Incidence map

  • Visualizing spatial data in R is straightforward with the plot() function.
  • Quick and simple plots help to better understand the data or optical verify results of an operation.
  • More sophisticated maps can be done with tmap or ggplot.
plot(kreiseWithCovidMeldeWeeklyCleaned["current_incidence"])

tm_shape(kreiseWithCovidMeldeWeeklyCleaned) + # spatial dataframe
  tm_polygons(  # type of visualization. for vectors: polygons, lines/borders, dots/symbols
    "current_incidence", # attribute field
    breaks = c(0, 5, 25, 50, 100, 250, 500, 1000), # class breaks
    legend.hist = TRUE, # show a histogram
    legend.reverse = T, # reverse the legend
    palette = "-plasma", # use plasma color ramp
    title = "Incidence 10/03/2021" # legend title
  ) +
  tm_layout(
    legend.show = T, 
    legend.outside = TRUE,
    bg.color = "darkgrey", 
    outer.bg.color = "lightgrey", 
    attr.outside = TRUE,
    legend.hist.width = .5,
    legend.hist.height = .5,
    legend.outside.position = "left"
  )

  • Maps that are not well thought out can lead to false assumptions
  • Choropleth maps: pre-defined areas are symbolized by an attribute
  • But is the attribute true for the whole area covered?
  • We don’t know about the distribution within the pre-defined areas
  • Modifiable area unit problem –> statistical bias from aggregating point phenomenons on arbitrary boundaries like districts
  • Well we don’t have the exact point referenced incidence data nor a higher resolution on e.g. community/neighborhood level
  • But we work with incidence rates and we know the population per district

  • There is no direct correlation between county area and county population
  • This can be problematic if for instance a couple of large areal units are affected by high incidence rates, but small populous are not
  • Its the same the other way around
Area % Pop %
Largest Units by area 9.6 2.4
Largest Units by pop 2 15

Alternative respresentations - cartograms

With the cartograms package we can transform our areal units by the population attribute. This way we include the absolute amount of population per unit to normalize the cartogram.

  1. The point distribution map randomly distributes a point for every 10,000th inhabitant
  2. The area distorted cartogram (Dougenik et al. 1985) expands/shrinks polygons via a rubber sheet distortion algorithm
  3. The dorling cartogram (Dorling 1996) builds non-overlapping circles where the size represents attribute for normalization.
load("data/kreiseWithCovidMeldedatumWeekly.Rdata")

# point distribution map
kreiseWithCovidMeldeWeeklyCleaned_pts10k <- kreiseWithCovidMeldeWeeklyCleaned %>%
    rowwise() %>%
    mutate(geometry = st_union(st_sample(geometry, size = EWZ/10000)))

# area distorted
kreiseWithCovidMeldeWeeklyCleaned_cart <- kreiseWithCovidMeldeWeeklyCleaned %>%
    cartogram_cont("EWZ")

# dorling
kreiseWithCovidMeldeWeeklyCleaned_dorling <- kreiseWithCovidMeldeWeeklyCleaned %>%
    cartogram_dorling("EWZ")

Weekly animation

With R and ffmpeg we are able to produce simple animations. Here is the example of the weekly incidence rate and it’s change from the previous week.

The table below lists selected covid related events in Germany by date.
Date Event
22.02.2020 Karneval (Rheinland)
27.02.2020 Heinsberg Hotspot
09.03.2020 Ischgl Hotspot
18.03.2020 TV Speech Chancelor Angela Merkel
22.03.2020 Begin Lockdown 1
02.04.2020 Peak wave 1
12.04.2020 Easter 2020
15.06.2020 Tönnies Skandal
28.10.2020 Begin lockdown 2
28.10.2020 Reinforcement measures lockdown 2
22.12.2020 Peak wave 2
25.12.2020 Christmas 2020
04.04.2021 Easter 2021
23.04.2021 Begin Lockdown 3 (Bundesnotbremse)
25.04.2021 Peak wave 3

Bivariate maps

In a later session we will assess what socio-economic factors may be linked to incidence rates. A simple first approach to visually compare the relation of two variables is a bivariate map. The two variables are classified into three quantiles and combined to 9.

Bivariate Classification scheme ( Joshua Stevens https://www.joshuastevens.net/cartography/make-a-bivariate-choropleth-map/)

Bivariate Classification scheme ( Joshua Stevens https://www.joshuastevens.net/cartography/make-a-bivariate-choropleth-map/)

Below an example of incidence all cases per Kreis and supply of broadband connection.

In order to create a bivariate map, you need to make sure you have a local copy of https://github.com/GIScience/global-health-academy/blob/main/auxiliary/bivariate_maps.R

source("auxiliary/bivariate_maps.R")

legend.viewport <- viewport(x = 0.2, y = 0.2, width = 0.4, height = 0.5)

create_bivar_map(crs_prj = 25832, dataset = kreiseWithCovidMeldeWeeklyCleanedPredictorsAdded,
    x = "sumCasesTotal", y = "Breitbandversorgung", x_label = "Current incidence",
    y_label = "Broadband supply", col.rmp = stevens.pinkgreen(9), ival.method = "quantile",
    fntsize = 0.75, vp = legend.viewport)


Back to overview

All contents are licensed under GNU General Public License v3.0