28 Day 26: Hydrology

28.1 Data Source: Maine Water

library(sf)
library(tigris)
library(hrbrthemes)
library(tidyverse)

c(
  "#366cff", "#4476ff", "#517fff", "#5f89ff", "#6c93ff", "#799dff", "#87a7ff", "#94b1ff",
  "#a1baff", "#afc4ff", "#bcceff", "#cad8ff", "#d7e2ff", "#e4ebff", "#f2f5ff", "#ffffff"
) -> pal

st_read(here::here("data/me-counties.json"), stringsAsFactors = FALSE) %>%
  st_set_crs(4326) -> me_counties
## Reading layer `cb_2015_maine_county_20m' from data source `/Users/hrbrmstr/books/30-day-map-challenge/data/me-counties.json' using driver `TopoJSON'
## Simple feature collection with 16 features and 10 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -71.08434 ymin: 43.05975 xmax: -66.9502 ymax: 47.45684
## epsg (SRID):    NA
## proj4string:    NA

pull(me_counties, NAME) %>%
  unique() %>%
  map(~area_water(state = "Maine", county = .x, class = "sf") %>%
        mutate(county = .x)) %>%
  do.call(rbind, .) -> me_aw

pull(me_counties, NAME) %>%
  unique() %>%
  map(~linear_water(state = "Maine", county = .x, class = "sf") %>%
        mutate(county = .x)) %>%
  do.call(rbind, .) -> me_rv

me_rv %>%
  mutate(
    sz = ifelse(grepl("(River|Rive|Riv)$", FULLNAME), 0.25, 0.04)
  ) -> me_rv

28.2 Drawing the Map

ggplot() +
  geom_sf(data = st_union(me_counties), fill = "#04005e", color = NA) +
  geom_sf(data = me_aw, size = 0, fill = "white", color = NA, show.legend = FALSE) +
  geom_sf(data = me_rv, aes(size = I(sz)), color = "white", fill = NA, show.legend = FALSE) +
  coord_sf(datum = NA) +
  labs(
    title = "Maine Hydrology",
    caption = "Data: {tigris} • #30DayMapChallenge"
  ) +
  theme_ipsum_es(grid="") +
  theme(plot.title = element_text(hjust = 0.5))

ggplot() +
  geom_sf(data = st_union(me_counties), fill = "white", color = "#04005e", size = 0.125) +
  geom_sf(data = me_aw, size = 0, fill = "#04005e", color = NA, show.legend = FALSE) +
  geom_sf(data = me_rv, aes(size = I(sz)), color = "#04005e", fill = NA, show.legend = FALSE) +
  coord_sf(datum = NA) +
  labs(
    title = "Maine Hydrology",
    caption = "Data: {tigris} • #30DayMapChallenge"
  ) +
  theme_ipsum_es(grid="") +
  theme(plot.title = element_text(color = "white", hjust = 0.5)) +
  theme(plot.caption = element_text(color = "white", hjust = 0.5)) +
  theme(plot.background = element_rect(color = "#04005e", fill = "#04005e")) +
  theme(panel.background = element_rect(color = "#04005e", fill = "#04005e"))

28.3 In Review

28.4 Try This At Home