-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathinset.R
63 lines (50 loc) · 1.45 KB
/
inset.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
library(rnaturalearth)
s <- states()
# filter for only contiguous states
skip <- c(
"Puerto Rico",
"Alaska",
"Hawaii",
"United States Virgin Islands",
"Commonwealth of the Northern Mariana Islands",
"American Samoa",
"Guam"
)
skinny_s <- s |>
filter(!NAME %in% skip)
skinny_s |>
ggplot() +
geom_sf()
l <- ne_download(type = "lakes", category = "physical", scale = "large") %>%
st_as_sf(., crs = st_crs(states))
lakes <- c("Lake Erie",
"Lake Michigan",
"Lake Superior",
"Lake Huron",
"Lake Ontario")
gl <- l %>%
filter(name %in% lakes) %>%
st_transform(crs = st_crs(skinny_s)) |>
st_union()
land <- ne_download(type = "land", category = "physical", scale = "large") %>%
st_as_sf() %>%
st_transform(., crs = st_crs(skinny_s)) |>
st_union()
skinny_s <- st_difference(skinny_s, gl)
skinny_s <- st_intersection(skinny_s, land)
mix <- mixcolor(alpha = .5, color1 = hex2RGB(header$colors[2]),
color2 = hex2RGB("#DaCab8")) |>
hex()
loc_plot <- skinny_s |>
ggplot() +
geom_sf(fill = NA, color = mix,
linewidth = .3) +
geom_sf(data = skinny_s |>
filter(NAME == "Nevada"),
fill = alpha(header$colors[6], .5),
color = header$colors[6],
linewidth = .5) +
coord_sf(crs = 2163, ylim = c(NA, 700000)) +
theme_void() +
scale_fill_identity()
ggsave(loc_plot, filename = glue("images/{header$map}/{header$pal}_inset.png"))