Consider where you are sitting. Think of the businesses you’re next to, the school district border you fall in, the socioeconomic makeup of your neighbors. Think about how that might change for the next person in the list for this class. Does it snow more often there or do they live in a more moderate climate? How far away from a grocery store are they compared to you? Is your quality of life better or worse? What opportunities are you missing out on that others might enjoy have based on where you are located?
When you’re able to analyze data in the framework of geography, you might be able to see patterns that you wouldn’t see otherwise.
There’s something tangible about visualizing data with maps. We recognize where we fit in the borders. It tells us who we are based on where we’ve been. And there’s more location data than ever before thanks to GPS-enable devices like phones, cameras, and vehicles.
Most spatial analysis is conducted with graphical programs like the (very expensive) ArcGIS and (free) QGIS. Recently, GIS work can be done online with Google Fusion Tables and Carto.
There’s a steep learning curve in using R to programmatically analyze and visualize spatial data. But the perks include approaching your work in a customizable, transparent, and reproducible way.
We’ll access the Census API to download data and use what we’ve already learned to join that data to shapefiles to make choropleth maps– both interactive and static.
We’ll do some digging into traffic stop data to find which neighborhoods are most racially profiled by police.
Mapping with sf and ggplot2
Getting latitude and longitude from addresses
Looking for racial profiling in traffic stops
Locator maps and geolocating addresses
With Starbucks and Census data
The repo for this class is on GitHub, but can be easily downloaded to your desktop with the following commands:
There are links to exercise what you’ve learned spread through out this section.
It’s possible to run these files locally to test yourself if you’ve downloaded the files for the chapter as instructed above.
Make sure your project directory is correct and then run these lines in the console:
install.packages("learnr") install.packages("rmarkdown") install.packages("tidyverse") install.packages("sf") install.packages("leaflet") install.packages("viridis")
© Copyright 2018, Andrew Ba Tran
© Copyright 2018, Andrew Tran