Space
Maps, Cartograms, and Choropleths
Slides and Tutorials
Spatial Data | Static Maps | Interactive Maps with Leaflet | Interactive Maps with Mapview |
Data |
Maps |
with leaflet |
with mapview |
“If we were to wake up some morning and find that everyone was the same race, creed, and color, we would find some other cause for prejudice by noon.”
— George D. Aiken, US senator (20 Aug 1892-1984)
Setting up R Packages
Plot Theme
Show the Code
# https://stackoverflow.com/questions/74491138/ggplot-custom-fonts-not-working-in-quarto
# Chunk options
knitr::opts_chunk$set(
fig.width = 7,
fig.asp = 0.618, # Golden Ratio
# out.width = "80%",
fig.align = "center"
)
### Ggplot Theme
### https://rpubs.com/mclaire19/ggplot2-custom-themes
theme_custom <- function() {
font <- "Roboto Condensed" # assign font family up front
theme_classic(base_size = 14) %+replace% # replace elements we want to change
theme(
panel.grid.minor = element_blank(), # strip minor gridlines
# text elements
plot.title = element_text( # title
family = font, # set font family
# size = 20, #set font size
face = "bold", # bold typeface
hjust = 0, # left align
# vjust = 2 #raise slightly
margin = margin(0, 0, 10, 0)
),
plot.subtitle = element_text( # subtitle
family = font, # font family
# size = 14, #font size
hjust = 0,
margin = margin(2, 0, 5, 0)
),
plot.caption = element_text( # caption
family = font, # font family
size = 8, # font size
hjust = 1
), # right align
axis.title = element_text( # axis titles
family = font, # font family
size = 10 # font size
),
axis.text = element_text( # axis text
family = font, # axis family
size = 8
) # font size
)
}
# Set graph theme
theme_set(new = theme_custom())
What graphs will we see today?
Variable #1 | Variable #2 | Chart Names | Chart Shape |
---|---|---|---|
Quant | Qual | Choropleth and Symbols Maps, Cartograms |
|
Inspiration
How do these Chart(s) Work?
In Figure 1 (a), we have a choropleth map. What does choropleth1 mean? And what kind of information could this map represent? The idea is to colour a specific area of the map, a district or state, based on a Quant or a Qual variable.
The Figure 1 (b) deliberately distorts and scales portions of the map in proportion to a Quant variable, in this case, population in 2018.
In Figure 2 (a) and Figure 2 (b), symbols are used to indicate either the location/presence of an item of interest, or a quantity by scaling their size in proportion to a Quant variable
Introduction
First; let us watch a short, noisy video on maps:
What kind of visualizations will we make?
Let us first understand the idea of a Geographical Information System, GIS:
We will first understand the structure of spatial data and where to find it. For now, we will deal with vector spatial data; the discussion on raster data will be dealt with in another future module.
We will get hands-on with making maps, both static and interactive.
Choropleth Map
Bubble Map
What information could this map below represent?
Let us now look at the slides. Then we will understand how the R packages sf
, tmap
work to create maps, using data downloadable into R using osmdata
and . We will also make interactive maps with osmplotr
leaflet
and mapview
; tmap
is also capable of creating interactive maps.
Your Turn
Animal and Bird Migration
- Head off to movebank.org. Look at a few species of interest and choose one.
- Download the data ( ESRI Shapefile). Note: You will get a .zip file with a good many files in it. Save all of them, but read only the
.shp
file into R. - Import that into R using
sf_read()
- See how you can plot locations, tracks and colour by species….based on the data you download.
- For tutorial info: https://movebankworkshopraleighnc.netlify.app/
UFO Sightings
Here is a UFO Sighting dataset, containing location and text descriptions. https://github.com/planetsig/ufo-reports/blob/master/csv-data/ufo-scrubbed-geocoded-time-standardized.csv
Sales Data from kaggle
Head off to Kaggle and search for Geographical Sales
related data. Make both static and interactive maps with this data. Justify your decisions for type of map.
References
Hadley Wickham, Danielle Navarro and Thomas Lin Pedersen. ggplot2: Elegant Graphics for Data Analysis, https://ggplot2-book.org/maps.html
Robin Lovelace, Jakub Nowosad, Jannes Muenchow. Geocomputation with R, https://r.geocompx.org/
Emine Fidan. Guide to Creating Interactive Maps in R, https://bookdown.org/eneminef/DRR_Bookdown/
Nikita Voevodin. R, Not the Best Practices, https://bookdown.org/voevodin_nv/R_Not_the_Best_Practices/maps.html
Want to make a cute logo-like map? Try https://prettymapp.streamlit.app
R Package Citations
Footnotes
Etymology. From Ancient Greek χώρα (khṓra, “location”) + πλῆθος (plêthos, “a great number”) + English map. First proposed in 1938 by American geographer John Kirtland Wright to mean “quantity in area,” although maps of the type have been used since the early 19th century.↩︎
Citation
@online{2022,
author = {},
title = {\textless Iconify-Icon Icon=“gis:proj-Geo” Width=“1.2em”
Height=“1.2em”\textgreater\textless/Iconify-Icon\textgreater{}
{Space}},
date = {2022-08-15},
url = {https://av-quarto.netlify.app/content/courses/Analytics/Descriptive/Modules/90-Space/},
langid = {en},
abstract = {Geospatial Data and how to use it with intent}
}