• Evaluate the effects of human movement patterns in infectious disease transmission like Dengue or Malaria.
Figure 2. (A) Human mobility by follow-up GPS tracks (Falcón-Lezama et al. 2017). (B) Road network map of Kenia with traffic data (Pindolia et al. 2012).
• Both of them are depicted in a map using Lines.
• Each Thematic map has its respective type of Geometry.
• There are three main geometry types: points, lines and polygons.
Figure 2. Geometry types and example maps for each. Points, lines (or linestrings) and polygons are the most common geometries you will encounter.
5 Multiple layer maps
• Most maps need additional geographic context.
• Plotting multiple geometries in overlapped layers.
• Complement Thematic maps with Physical features.
How to plot them?
• Let’s complement a Choropleth map with the population (pop_est) of African countries, from the africountries dataset with: the African trans-continental highway network lines, available in the afrihighway dataset from the same package.
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
---title: 'Physical Features'author: - name: 'Andree Valle Campos' - name: 'Laure Vancauwenberghe' - name: 'Kene David Nwosu'date: '2024-12-2'format: html: code-fold: true code-tools: true number-sections: true toc: true css: global/style/style.css---```{r, include = FALSE, warning = FALSE, message = FALSE}# Load packages if(!require(pacman)) install.packages("pacman")pacman::p_load(tidyverse, knitr, here)# Source functions source(here("global/functions/misc_functions.R"))# knitr settingsknitr::opts_chunk$set(warning = F, message = F, class.source = "tgc-code-block", error = T)``````{r,echo=FALSE}ggplot2::theme_set(new = theme_bw())options(scipen=10000)```------------------------------------------------------------------------## Introduction• Spatial data may require **geographic context**• Aids to locate events with *environmental features* like streets.• Today, we are going to learn:• How to add **Physical features** to our maps, and• How to plot them in **multiple layers** to complement Thematic maps!------------------------------------------------------------------------## Learning objectives1. Create **Physical feature maps** to visualize roads or rivers.2. Complement **Thematic maps** with Physical features as background.3. Relate Physical features with a **Geometry** type.------------------------------------------------------------------------## PrerequisitesThis lesson requires the following packages:```{r,eval=TRUE,echo=TRUE,message=FALSE}if(!require('pacman')) install.packages('pacman')pacman::p_load_gh("afrimapr/afrilearndata")pacman::p_load(ggspatial, ggplot2, tibble, mdsr, terra, spData, sf, readr)```This lesson requires familiarity with `{ggplot2}`: if you need to brush up, have a look at our introductory course on data visualization.------------------------------------------------------------------------## Physical features### What are they? {.unnumbered}• *Physical features* include roads, buildings and rivers.### How to plot them? {.unnumbered}• Using `{ggplot2}`, `geom_sf()`, and the `color` argument.#### With Categorical data {.unlisted .unnumbered}• Let's map the Road network in South America and `color` them according to their type:```{r}south_am_roads <-read_rds(here("data/south_am_roads.rds"))ggplot(south_am_roads) +geom_sf(mapping =aes(color = type))```::: r-practiceLet's create a map of the Sacramento basin in California US (`sacramento_rivers`), colored by their feature type (`FTYPE`).```{r,eval=FALSE}sacramento_rivers <- read_rds(here("data/sacramento_rivers.rds"))# CONTINUE YOUR CODE HEREggplot(sacramento_rivers) + geom_sf(mapping = aes(color = FTYPE), size = 1)```Data from here: <https://zenodo.org/record/4985219>:::#### With Quantitative data {.unlisted .unnumbered}• We can use it in Environmental Epidemiology,• The concentration of chemicals or pollutants in wastewater surveillance.• In Ecology, richness estimations from rivers.• Let's map a *classification* of rivers in the Sacramento basin in California US.```{r}sacramento_rivers <-read_rds(here("data/sacramento_rivers.rds"))ggplot(data = sacramento_rivers) +geom_sf(mapping =aes(color = richness))```• "Richness" is the estimated number of fish species in each segment of the river.::: r-practiceCreate a Thematic map of the road network in South America, using the `south_am_roads` dataset, colored by the length in Km (`length_km`) of each road.```{r,eval=FALSE}ggplot(data = south_am_roads) + geom_sf(mapping = aes(color = length_km), size = 1)```:::### How to use it? {.unnumbered}• *Trajectory data* and *Road network data*• Evaluate the effects of human movement patterns in infectious disease transmission like [Dengue](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0172313) or [Malaria](https://malariajournal.biomedcentral.com/articles/10.1186/1475-2875-11-205).{width="540"}• Both of them are depicted in a map using **Lines**.::: recap• Each **Thematic map** has its respective type of *Geometry*.• There are three main geometry types: *points*, *lines* and *polygons*.{width="555"}:::------------------------------------------------------------------------## Multiple layer maps• Most maps need additional geographic context.• Plotting multiple geometries in overlapped layers.• Complement Thematic maps with *Physical features*.### How to plot them? {.unnumbered}• Let's complement a Choropleth map with the population (`pop_est`) of African countries, from the `africountries` dataset with: the African trans-continental highway network lines, available in the `afrihighway` dataset from the same package.```{r,eval=TRUE}ggplot() + geom_sf(data = africountries , mapping = aes(fill = pop_est)) + geom_sf(data = afrihighway)```• Here, the physical feature `afrihighway` is [**above**]{.underline} all the other layers.• But it can also be [**below**]{.underline}.• We can complement a Dot map from `africapitals`, with the same `afrihighway` layer:```{r,eval=TRUE}ggplot() + geom_sf(data = afrihighway) + geom_sf(data = africapitals, mapping = aes(size = pop, color = pop))```• This is how you plot another map layer on top of another map.::: recap• `{ggplot2}` allows to **overlap multiple layers (of maps)** to complement Thematic maps.• For this, You need a **local** specification of data:``` r# instead of:ggplot(data = data_global) +geom_sf()# we use:ggplot() +geom_sf(data = data_local_layer_1) +geom_sf(data = data_local_layer_2)```:::• *Order* of layers (below or above) depend on the aim.::: practiceCreate a multiple layer Thematic map with:- the `world` dataset (from the `{spData}` package).- Then, overlap it with the African trans-continental highway network lines from the `afrihighway` dataset.Use the `geom_sf()` function for each layer:```{r,eval = FALSE} ggplot() + geom_sf(data = world) + geom_sf(data = afrihighway)```:::### How to use it? {.unnumbered}• In scenarios similar to John Snow's *Dot map*• Locations of deaths of the 1854 London cholera outbreak.• Complemented with a *physical feature* like the *street roads* of the city:• In Figure 3B, the *physical feature* is below the Dot map.• This is why it looks much more readable.------------------------------------------------------------------------## Wrap up• How to represent *Physical features* and• How to use them to *complement* Thematic maps in *multiple layers*.• However, you may require a *more explicit* background!• For example, *Basemaps* for Google Maps-like backgrounds.• See you in the next lesson!------------------------------------------------------------------------## Contributors {.unlisted .unnumbered}The following team members contributed to this lesson:`r tgc_contributors_list(ids = c("avallecam", "lolovanco", "kendavidn"))`------------------------------------------------------------------------## References {.unlisted .unnumbered}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>`r tgc_license()`------------------------------------------------------------------------## Answer Key {.unnumbered}### Q1 {.unlisted .unnumbered}```{r}sacramento_rivers <-read_rds(here("data/sacramento_rivers.rds"))ggplot(data = sacramento_rivers) +geom_sf(aes(color = FTYPE), size =1)```### Q2 {.unlisted .unnumbered}```{r}south_am_roads <-read_rds(here("data/south_am_roads.rds"))ggplot(data = south_am_roads) +geom_sf(aes(color = length_km), size =1)```### Q3 {.unlisted .unnumbered}```{r}ggplot() +geom_sf(data = world) +geom_sf(data = afrihighway)```