boB Rudis 4 years ago
parent
commit
fe748dfea1
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 16
      2019-11-25-climate.R
  2. 77
      2019-11-26-hydrology.R

16
2019-11-25-climate.R

@ -1,14 +1,14 @@
library(sf)
library(albersusa) # hrbrmstr/albersusa
library(rnaturalearth)
library(hrbrthemes)
library(tidyverse)
#https://www.ncdc.noaa.gov/ibtracs/
st_read(here::here("data/me-counties.json")) %>%
st_set_crs(4326) %>%
st_transform(albersusa::us_laea_proj) -> maine
rnaturalearth::ne_states("united states of america", returnclass = "sf") %>%
ne_states("united states of america", returnclass = "sf") %>%
filter(!(postal %in% c("AK", "HI"))) %>%
st_transform(albersusa::us_laea_proj) -> states
@ -85,10 +85,8 @@ ggplot() +
gb,
xmin = -2031896.9,
xmax = 7725851.8,
ymin = 2150000.0, # #732581.2,
ymin = 2150000.0,
ymax = 5685229.4
# ymin = 1500000.0, # #732581.2,
# ymax = 4685229.4
) +
geom_sf(data = states, color = "white", fill = "#3B454A", size = 0.0725) +
geom_sf(data = maine, size = 0.125) +
@ -108,9 +106,3 @@ ggplot() +
theme(legend.direction = "horizontal") +
theme(legend.key.width = unit(2, "lines")) +
theme(legend.title = element_text(hjust = 1))

77
2019-11-26-hydrology.R

@ -0,0 +1,77 @@
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
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
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"
) +
theme_ipsum_es(grid="") +
theme(plot.title = element_text(color = "white")) +
theme(plot.background = element_rect(color = "black", fill = "black")) +
theme(panel.background = element_rect(color = "black", fill = "black"))
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} • <git.rud.is/hrbrmstr/y2019-30daymapchallenge> • #30DayMapChallenge"
) +
theme_ipsum_es(grid="") +
theme(plot.title = element_text(hjust = 0.5))
# vern <- st_read("~/Desktop/Maine_Significant_Vernal_Pools/Maine_Significant_Vernal_Pools.shp", stringsAsFactors=FALSE)
#
# st_intersection(vern, st_transform(me_counties, st_crs(vern))) %>%
# filter(NAME == "York") -> yc_vern
#
# ggplot() +
# geom_sf(data = yc_vern[10,], color = NA, fill = "white") +
# coord_sf(datum = NA) +
# theme_ipsum_es(grid="") +
# theme(plot.background = element_rect(color = "black", fill = "black")) +
# theme(panel.background = element_rect(color = "black", fill = "black"))
#
#
unique(as.character(me_rv$FULLNAME)) %>%
stringi::stri_match_last_regex(" ([[:alpha:]]+)$") %>%
.[,2] %>%
unique() %>% sort()
Loading…
Cancel
Save