1. Advanced demographic mapping
In the previous lesson, you learned how to make choropleth maps to show geographic trends in US Census data. However, there are many other alternatives for mapping of US Census Bureau demographic data. In this lesson, you'll learn about techniques such as graduated symbol mapping, faceted mapping, and interactive visualization.
2. Visual variables in cartography
Aside from color, there are many methods cartographers can use to display variation on a map, which is summarized in this graphic of visual variables from Axis Maps. The most common in cartography is position, as elements will be distinguished by their geographic location relative to other elements. However, the cartographer might decide to modify the size, shape, orientation, or texture of map elements or symbols to illustrate how characteristics of the data vary in magnitude and over space.
3. Graduated symbol maps
The graduated symbol map is a popular cartographic method that uses the visual variable size to show differences in attribute magnitude. In the graduated symbol map, a given shape is differentially sized depending on its corresponding data value.
In this example, we are using the state median home value dataset introduced earlier in this chapter, but mapping it with circles superimposed over the shapes of their corresponding states. To accomplish this, we use the st_centroid() function in the sf package to place a point at the center of each state. We then make two calls to geom_sf() to plot both the state boundaries as contextual information and the state centers sized by the ACS estimate.
4. Graduated symbol maps
Here, we see an unpolished exploratory map illustrating the result. States with higher median home values are represented with larger circles; Hawaii, California, and states in the Northeastern US stand out. Smaller circles then represent lower median home values, as seen in states in the southeastern and midwestern US. While perceiving size differences can be easier for some viewers than perceiving color differences, there are some disadvantages to graduated symbol maps, exemplified here by the overlapping of symbols in the northeastern US.
5. Small multiples
Another popular technique for data visualization is the small multiples plot. In this type of visualization, data are separated into groups based on the unique values of a column in the dataset, and plots are generated for each of those groups. This facilitates group-wise comparisons, as evidenced by the kernel density plots on the slide for four counties in North Texas. The plot, which is generated based on Census-tract level median household income in each county, allows viewers to compare these distributions between these counties readily.
6. Faceted maps with ggplot2
The facet_wrap() function in ggplot2 is a powerful way to generate small multiples plots, and this can be extended to map-making with geom_sf(). Here, we are using a dataset showing the percentage of the population that self-identifies as members of four racial and ethnic groups by Census tract in Washington, DC.
7. Interactive visualization
The advent of fast web-based visualization technologies in recent years has prompted an explosion of frameworks for interactive visualization of data on the web. The R developer community has wrapped many of these libraries, typically written in JavaScript, and made them available to R users. Popular libraries include the leaflet package for web mapping; plotly for interactive charting, and the suite of packages that use the htmlwidgets framework for binding JavaScript libraries to R.
8. Interactive maps with mapview
The quickest way to get started with interactive mapping in R is arguably the mapview package, which generates an explorable interactive map in a single line of code. In this example, we map the Cook County median home value dataset with the mapview() function, which lets us explore our data in a web browser.
9. Let's practice!
Now, you'll get to try this out yourself!