Created
November 6, 2018 18:11
-
-
Save andrewheiss/a0114af7d9475ba149bafe4b7973ebf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
library(scico) | |
# https://gis.utah.gov/data/boundaries/citycountystate/ | |
counties <- st_read("data/Counties/Counties.shp") | |
# https://gis.utah.gov/data/society/schools-libraries/ | |
libraries <- st_read("data/Libraries/Libraries.shp") | |
# Count the number of libraries per county | |
libraries_county <- libraries %>% | |
group_by(COUNTY) %>% | |
summarize(num_libraries = n()) %>% | |
# Make NAME uppercase for joining later | |
mutate(NAME = str_to_upper(COUNTY)) | |
# Merge the county-level library counts with the county data | |
counties_with_data <- counties %>% | |
st_join(libraries_county) %>% | |
mutate(people_per_library = POP_CURRES / num_libraries) | |
# Plot this! | |
ggplot() + | |
geom_sf(data = counties_with_data, aes(fill = people_per_library), size = 0.25) + | |
geom_sf(data = libraries, size = 0.5) + | |
coord_sf(crs = 26912, datum = NA) + | |
scale_fill_scico(palette = "bilbao", end = 0.9, | |
labels = scales::comma, na.value = "white", | |
name = "People per library") + | |
guides(fill = guide_colorbar(barwidth = 10, barheight = 1)) + | |
labs(title = "Libraries in Utah", | |
subtitle = "Davis and Weber counties seem to be the most\nunderserved given their populations") + | |
theme_void(base_family = "Clear Sans") + | |
theme(legend.position = "bottom", | |
plot.title = element_text(face = "bold")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the final map