Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created September 22, 2020 15:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewheiss/3abbe58158a937f0d8069952f798e334 to your computer and use it in GitHub Desktop.
Save andrewheiss/3abbe58158a937f0d8069952f798e334 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(tidygeocoder)
library(sf)
library(albersusa)
places <- tribble(
~name, ~address,
"My empty GSU office", "14 Marietta Street NW, Atlanta, GA 30303",
"My old BYU office", "155 East 1230 North, Provo, UT 84604",
"My old Duke office", "201 Science Dr, Durham, NC 27708"
) %>%
geocode(address, method = "census", lat = latitude, long = longitude) %>%
st_as_sf(coords = c("longitude", "latitude"), crs = 4326)
lower_48 <- usa_sf("longlat") %>% filter(!(iso_3166_2 %in% c("AK", "HI", "DC")))
update_geom_defaults("label", list(family = "Asap Condensed SemiBold"))
ggplot() +
geom_sf(data = lower_48, size = 0.25, fill = "grey95") +
geom_sf(data = places, color = "#FF4136") +
geom_sf_label(data = places[1,], aes(label = name), nudge_y = -150000) +
geom_sf_label(data = places[2:3,], aes(label = name), nudge_y = 150000) +
coord_sf(crs = 5070) + # Albers
theme_void()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment