Skip to content

Instantly share code, notes, and snippets.

@cbgoodman
Last active November 5, 2022 19:26
Show Gist options
  • Save cbgoodman/1c129fa258714e60468da773118971a8 to your computer and use it in GitHub Desktop.
Save cbgoodman/1c129fa258714e60468da773118971a8 to your computer and use it in GitHub Desktop.
library("tidyverse")
library("tidycensus")
census_api_key("INSERT_API_KEY")
wright <- get_acs(
state = "MN",
county = "Wright",
geography = "county subdivision",
variables = "B19013_001",
geometry = TRUE,
year = 2020
) %>%
# filter out the townships
filter(str_detect(NAME, regex("city", ignore_case = TRUE)))
# get the county outline
wright_county <- get_acs(
state = "MN",
county = "Wright",
geography = "county",
variables = "B19013_001",
geometry = TRUE,
year = 2020
)
ggplot() +
geom_sf(wright_county, mapping = aes(), color = "black") +
geom_sf(wright, mapping = aes(), color = NA, fill = "white")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment