23  Advanced Spatial Visualization

Today we will be focusing on the theory and practice of fancy geospatial data visualization.

23.1 Visual Categories and Encodings

Let’s go back to the beginning of this course. There are 3 categories of information that can be displayed.

  1. Quantitative
  2. Qualitative
  3. Spatial

Lecture 1.2.1

The three types of data can be encoded in:

  • Geometric primitives - points, lines, and areas
  • Visual channels - size, color, shape, position, angle, and texture

An advanced spatial visualization covering multiple layers of information needs to use multiple sets of encodings to convey information quickly and intuitively while not overwhelming the audience.

23.2 Circles, Lines, and Polygons - Oh My!

Fancy maps need distinct visual encodings, so the eye can be drawn the salient features.

One key way to do this is through ensuring different types/styles/aesthetics are displayed as unique fingerprints of visual encodings.

Let’s combine the three datasets we have showed in class for the sacrifice zones projects as example 1.

First, get all the libraries we need loaded up.

23.2.1 Example 1 - Uranium Mines and Navajo Lands

23.2.1.1 Acquire datasets

23.2.1.1.1 US EPA Uranium Mills and Mines Database

Here’s a geospatial dataset the EPA created for abandoned uranium mines in the Western US. It is downloadable as a zip file, which has multiple subdirectories. We will point to the master database as a first exploration.

U <- sf::st_read(dsn = 'uld-ii_gis/Master_Database_and_Shape_Files') %>% 
  st_transform(crs = 4326)
Multiple layers are present in data source C:\Dev\EnviroDataVis\uld-ii_gis\Master_Database_and_Shape_Files, reading layer `ULD_albers'.
Use `st_layers' to list all layer names and their type in a data source.
Set the `layer' argument in `st_read' to read a particular layer.
Warning in evalq((function (..., call. = TRUE, immediate. = FALSE, noBreaks. =
FALSE, : automatically selected the first layer in a data source containing more
than one.
Reading layer `ULD_albers' from data source 
  `C:\Dev\EnviroDataVis\uld-ii_gis\Master_Database_and_Shape_Files' 
  using driver `ESRI Shapefile'
Simple feature collection with 14810 features and 30 fields
Geometry type: MULTIPOINT
Dimension:     XY
Bounding box:  xmin: -3296195 ymin: -1542681 xmax: 1955673 ymax: 4183792
Projected CRS: North_America_Albers_Equal_Area_Conic
23.2.1.1.2 Make some exploratory maps

Let’s see what the basic mines dataset looks like.

Figure 23.1

leaflet() %>% 
  addTiles() %>% 
  addMarkers(data = U,
                   lat = ~LATITUDE,
                   lng = ~LONGITUDE,
                   clusterOptions = markerClusterOptions())

Figure 23.1: Basic map of uranium mines

There are WAY more uranium mines than I expected. Let’s focus on areas near the Navajo Nation in the four-corners states of Colorado, New Mexico, Arizona, and Utah.

Let’s filter() the U dataset to the spatial scale of interest using the STATE_NAME column.

states <- c('Colorado', 'New Mexico', 'Arizona', 'Utah')
#not the band
U2 <- U %>% 
  filter(STATE_NAME %in% states)

Ok, let’s look at that and see if we are limiting our dataset.

Figure 23.2 shows the four-corners mines.

leaflet() %>% 
  addTiles() %>% 
  addProviderTiles(provider = providers$Stamen.Terrain) %>% 
  addCircleMarkers(data = U2,
                   lat = ~LATITUDE,
                   lng = ~LONGITUDE,
                   clusterOptions = markerClusterOptions(),
                   color = 'darkred',
                   label = ~htmlEscape(MINENAME)) %>% 
  addMiniMap()

Figure 23.2: Uranium mines in the four corners states

23.2.1.1.3 Tribal Lands

Federally recognized tribal lands are available here

It is downloadable as a zip file, which needs to be extracted.

After extracting it into the working directory, the default extracted directory is tl_2020_us_aitsn on my machine.

Let’s do the steps - import, display a simple map, then display a fancy map.

tribalLands <- sf::st_read(dsn = 'tl_2020_us_aitsn') %>% 
  st_transform(crs = 4326)
Reading layer `tl_2020_us_aitsn' from data source 
  `C:\Dev\EnviroDataVis\tl_2020_us_aitsn' using driver `ESRI Shapefile'
Simple feature collection with 484 features and 14 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -124.0932 ymin: 31.50786 xmax: -83.15622 ymax: 48.63591
Geodetic CRS:  NAD83

Make a simple map next.

I am not displaying the basic example because my course website is limited to 100 MB, but the code does work.

leaflet() %>% 
  addTiles() %>% 
  addPolygons(data = tribalLands,
              weight = 1) 

That worked. Let’s try to combine the Uranium mines map with the tribal lands of the Navajo Nation using setView(). I clicked on a google map to get the lat (36.481) and lng (-109.495).

Figure 23.3 shows the result.

leaflet() %>% 
  addTiles() %>% 
  #addProviderTiles(provider = providers$Stamen.Terrain) %>% 
  setView(lng = -109.495, lat = 36.481, zoom = 7) %>% 
  addPolygons(data = tribalLands,
              weight = 1, 
              color = 'blue',
              fillOpacity = 0.2) %>% 
  addCircleMarkers(data = U2,
                   lat = ~LATITUDE,
                   lng = ~LONGITUDE,
                   clusterOptions = markerClusterOptions(),
                   color = 'darkred',
                   label = ~htmlEscape(MINENAME)) %>% 
  addMiniMap()