library(ggtext) #html in figure captions
library(ggplot2)
library(sf)
library(showtext) #for tron font
library(dplyr)
Am-tron
Day 2 of the #30DayMapChallenge - Lines
The goal of today is to make a Tron-style map of the Amtrak lines in the US.
I downloaded the shapefile of Amtrak routes from the US Department of Transportation Open Data Dashboard. But there were some errors with non-overlapping vertices so I ended up just georeferencing it myself in QGIS before starting.
Most of the work today was just messing about with code to get the aesthetics I wanted. First we load the data:
#georeferenced
<- st_read("amtrak-manual.gpkg") %>%
amtrak st_transform(crs = 5070)
Reading layer `amtrak-manual' from data source
`/Users/mvevans/Dropbox/git/quarto-blog/posts/2022-30daymapping/day2-lines/amtrak-manual.gpkg'
using driver `GPKG'
Simple feature collection with 38 features and 0 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: -123.1859 ymin: 25.81329 xmax: -70.00839 ymax: 49.2478
Geodetic CRS: WGS 84
#outline of us
<- st_as_sf(maps::map("usa", fill=TRUE, plot =FALSE)) %>%
usa.poly filter(ID == "main") %>%
st_transform(crs = 5070)
And then map it:
<- c(-1.2e6, 2.5e5)
caption.pos
<- ggplot() +
amtron geom_sf(data = usa.poly, fill = "gray30", color = "gray80", size = 0, alpha = 0.8) +
geom_sf(data = amtrak, color = "#6EECED", size = 2.5, alpha = 0.15) +
geom_sf(data = amtrak, color = "#6EECED", size = 3, alpha = 0.1) +
geom_sf(data = amtrak, color = "#6EECED", size = 2, alpha = 0.2) +
geom_sf(data = amtrak, color = "#6EECED", size = 1.5, alpha = 0.2) +
geom_sf(data = amtrak, color = "#6EECED", size = 1, alpha = 0.5) +
geom_sf(data = amtrak, color = "#6EECED", size = 0.75, alpha = 0.2) +
annotate("text", x = caption.pos[1], y = caption.pos[2], label = "AMTRON", color = "#d3b3f2", size = 13,
family = "tron") +
annotate("text", x = caption.pos[1], y = caption.pos[2], label = "AMTRON", color = "#6EECED", size = 14,
family = "tron", alpha = 0.3) +
annotate("text", x = caption.pos[1], y = caption.pos[2], label = "AMTRON", color = "white", size = 16,
family = "tron", alpha = 0.1) +
coord_sf(clip = "off") +
labs(caption = "**Source:** US DOT, maps package <br>
**Created by:**M. Evans") +
theme_void() +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
plot.caption = element_markdown(color = "gray90", size = 10, hjust = ),
plot.caption.position = "plot")
amtron