Geospatial visualization
Introduction to geospatial visualization
Geospatial visualizations are one of the earliest forms of information visualizations. They were used historically for navigation and were essential tools before the modern technological era of humanity. Data maps were first popularized in the seventeenth century and have grown in complexity and detail since then.
Drawing raster maps with ggmap
library(tidyverse) library(ggmap) library(RColorBrewer) library(patchwork) library(here) options(digits = 3) set.seed(1234) theme_set(theme_minimal()) ggmap is a package for R that retrieves raster map tiles from online mapping services like Google Maps and plots them using the ggplot2 framework.
Practice drawing raster maps
library(tidyverse) library(ggmap) library(RColorBrewer) library(here) options(digits = 3) set.seed(1234) theme_set(theme_minimal()) Chicago 311 data The city of Chicago has an excellent data portal publishing a large volume of public records. Here we’ll look at a subset of the 311 service requests.
Importing spatial data files using sf
library(tidyverse) library(sf) library(here) options(digits = 3) set.seed(1234) theme_set(theme_minimal()) Rather than storing spatial data as raster image files which are not easily modifiable, we can instead store spatial data as vector files.
Drawing vector maps with simple features and ggplot2
library(tidyverse) library(sf) library(here) options(digits = 3) set.seed(1234) theme_set(theme_minimal()) Unlike raster image maps, vector maps require you to obtain spatial data files which contain detailed information necessary to draw all the components of a map (e.
Practice drawing vector maps
library(tidyverse) library(sf) library(tidycensus) library(viridis) # useful on MacOS to speed up rendering of geom_sf() objects if (!identical(getOption("bitmapType"), "cairo") && isTRUE(capabilities()[["cairo"]])) { options(bitmapType = "cairo") } options(digits = 3) set.seed(1234) theme_set(theme_minimal()) American Community Survey The U.
Selecting optimal color palettes
library(tidyverse) library(sf) library(tidycensus) library(RColorBrewer) library(patchwork) # useful on MacOS to speed up rendering of geom_sf() objects if (!identical(getOption("bitmapType"), "cairo") && isTRUE(capabilities()[["cairo"]])) { options(bitmapType = "cairo") } options(digits = 3) set.seed(1234) theme_set(theme_minimal()) Selection of your color palette is perhaps the most important decision to make when drawing a choropleth.