Thematic maps portrait geographic patterns about a particular subject theme in a geographic area. In the context of epidemiological outbreaks, these maps can be called Epidemic maps.
In this lesson we are going to learn about the most iconic types of Thematic maps to visualize your spatial data: Choropleth maps and Dot maps.
Identify two types of Thematic maps (choropleth and dot maps) used by epidemiologist to visualize Geospatial data.
Create Thematic maps using {ggplot2}
and the
geom_sf()
function.
Relate each Thematic map with a Geometry type.
This lesson requires the following packages:
if(!require('pacman')) install.packages('pacman')
pacman::p_load_gh("afrimapr/afrilearndata")
pacman::p_load(rnaturalearth,
ggspatial,
ggplot2,
mdsr,
terra,
spData,
readr)
This lesson requires familiarity with {ggplot2}
: if you
need to brush up, have a look at our introductory course on data
visualization.
A Choropleth map is a type of thematic map where colors, shading, or patterns are used to represent geographic regions in relation to the value of an attribute.
For instance a larger value could be indicated by a darker color, while a smaller value could be indicated by a lighter color.
Geospatial data can be plotted with the {ggplot2}
package, using the geom_sf()
function.
Information such as colors and shapes can be depicted
using the aes()
function with the fill
,
color
and size
arguments.
A Choropleth map will usually require using the
fill
argument. Let’s create a Choropleth map!
We are going to use the africountries
dataset from the
{afrilearndata}
package. It contains the administrative
boundaries of all the countries in the African continent.
{ggplot2}
and the geom_sf()
function to plot African countries,fill
each of them in relation to the estimated
population (pop_est
) of each country:sf
stands for “simple features”, an open
standard used to represent a wide range of geometric
shapes.
This type of map is particularly useful when visualizing a variable and how it changes across defined regions or geopolitical areas.
In Figure 2, the region of interest (Sierra Leone) has been partitioned into a finite number of subregions (districts) at which the number of cases have been aggregated.
The type of shape that Choropleth maps visualize is called Polygons. This shape collects data that pertains to an enclosed region partitioned into a finite number of areal units with well-defined boundaries. For example, attributes collected by ZIP code, census tract, or the administrative boundary levels of a country (Figure 2).
A Dot map is a thematic map type that uses dots to represent attribute values in your data.
The Dot map could use the size
or
color
argument.
A Quantitative Dot map requires the size
argument. Let’s
create a Dot map!
Let’s use the africapitals
dataset, also from the
{afrilearndata}
package, which contains the location of
capital cities in the African continent.
{ggplot2}
and geom_sf()
to plot these locations,size
each of them in relation to their number of
inhabitants:This type of map is best used to visualize the scatter of your data and visually scan for clusters.
The type of shape that Dot maps visualize is called Point. This shape collects data that register the locations of random events. For example, collecting geographical coordinates of individuals with a given diagnosis (Figure 3): the Ebola cases in Sierra Leone.
Are you bothered by the fact of having just dots and no country lines or any geographical context? That’s good! We will see how to add those using roads and rivers, also known as Physical features, very soon.
Thematic maps visualize specific shapes or Geometry types:
Which of the following options of Thematic map types:
"choropleth_map"
"dot_distribution_map"
…corresponds to each of these Epidemic map figures?
Your answer should be either “choropleth_map” or “dot_distribution_map”.
In this lesson, we learned about Thematic maps, how to
create them using {ggplot2} and the
geom_sf()
function, and which type of
Geometry they visualize.
But, how can we complement Thematic maps with geographic context? Or how can we avoid overlapped points when needed? In the following lessons, we are going to learn about how to add Physical features to our maps and use Density maps to avoid overlaps in them!
Which of the following options of Thematic map types corresponds to each of these Epidemic map figures? Your answer should be either “choropleth_map” or “dot_distribution_map”.
The following team members contributed to this lesson:
Some material in this lesson was adapted from the following sources:
Batra, Neale, et al. (2021). The Epidemiologist R Handbook. Chapter 28: GIS Basics. (2021). Retrieved 01 April 2022, from https://epirhandbook.com/en/gis-basics.html
Lovelace, R., Nowosad, J., & Muenchow, J. Geocomputation with R. Chapter 2: Geographic data in R. (2019). Retrieved 01 April 2022, from https://geocompr.robinlovelace.net/spatial-class.html
Moraga, Paula. Geospatial Health Data: Modeling and Visualization with R-INLA and Shiny. Chapter 2: Spatial data and R packages for mapping. (2019). Retrieved 01 April 2022, from https://www.paulamoraga.com/book-geospatial/sec-spatialdataandCRS.html
Baumer, Benjamin S., Kaplan, Daniel T., and Horton, Nicholas J. Modern Data Science with R. Chapter 17: Working with geospatial data. (2021). Retrieved 05 June 2022, from https://mdsr-book.github.io/mdsr2e/ch-spatial.html
This work is licensed under the Creative Commons Attribution Share Alike license.