boB Rudis
4 years ago
5 changed files with 177 additions and 0 deletions
@ -0,0 +1,79 @@ |
|||
library(sf) |
|||
library(tigris) |
|||
library(patchwork) |
|||
library(hrbrthemes) |
|||
library(tidyverse) |
|||
|
|||
if (!file.exists(here::here("data/me-topo.geojson"))) { |
|||
download.file("http://techslides.com/demos/d3/us/data/me.topo.json", here::here("data/me-topo.geojson")) |
|||
} |
|||
|
|||
st_read(here::here("data/me-topo.geojson")) %>% |
|||
st_set_crs(4326) %>% |
|||
st_transform("+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs") -> towns |
|||
|
|||
st_read(here::here("data/me-counties.json")) %>% |
|||
st_set_crs(4326) %>% |
|||
st_transform("+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs") -> maine |
|||
|
|||
filter(maine, NAME == "York") -> york |
|||
|
|||
rivers <- linear_water(state = "ME", "York", class="sf") |
|||
water <- area_water(state = "ME", "York", class = "sf") |
|||
|
|||
dsn <- "~/Desktop/ME_West_slr_data_dist/ME_West_slr_final_dist.gdb/" |
|||
|
|||
st_layers(dsn) |
|||
|
|||
x <- st_read(dsn, "ME_West_low_1ft", options=list("METHOD=SKIP")) |
|||
x <- st_intersection(st_buffer(x, 0), york) |
|||
|
|||
y <- st_read(dsn, "ME_West_low_10ft", options=list("METHOD=SKIP")) |
|||
y <- st_intersection(st_buffer(y, 0), york) |
|||
|
|||
york_towns <- st_intersection(st_buffer(towns, 0), york) |
|||
|
|||
ggplot() + |
|||
geom_sf(data = maine, fill = "#efefef", size = 0.25) + |
|||
geom_sf(data = york, fill = "#efefef", size = 0.125) + |
|||
# geom_sf(data = water, fill = "#8cb6d3", color = "#8cb6d3") + |
|||
geom_sf(data = rivers, size = 0.075, color = "#8cb6d366") + |
|||
geom_sf(data = x, fill = "#bd002666", color = "#bd002666") + |
|||
geom_sf_text(data = maine, aes(label = NAME), family = font_es_bold, size = 3.25, color="white") + |
|||
geom_sf_text(data = maine, aes(label = NAME), family = font_es_light, size = 3) + |
|||
coord_sf(datum = NA) + |
|||
labs( |
|||
x = NULL, y = NULL |
|||
) + |
|||
theme_ipsum_es(grid="") -> gg |
|||
|
|||
ggplot() + |
|||
geom_sf(data = york, fill = "#efefef", size = 0.25) + |
|||
geom_sf(data = water, fill = "#8cb6d3", color = "#8cb6d3") + |
|||
geom_sf(data = rivers, size = 0.1, color = "#8cb6d3") + |
|||
geom_sf_text(data = york_towns, aes(label = id), family = font_es_bold, size = 2.25, color="white") + |
|||
geom_sf_text(data = york_towns, aes(label = id), family = font_es_light, size = 2) + |
|||
geom_sf(data = x, fill = "#bd002666", color = "#bd002666") + |
|||
coord_sf(datum = NA) + |
|||
labs( |
|||
x = NULL, y = NULL |
|||
) + |
|||
theme_ipsum_es(grid="") -> gg1 |
|||
|
|||
ggplot() + |
|||
geom_sf(data = york, fill = "#efefef", size = 0.25) + |
|||
geom_sf(data = water, fill = "#8cb6d3", color = "#8cb6d3") + |
|||
geom_sf(data = rivers, size = 0.1, color = "#8cb6d3") + |
|||
geom_sf(data = x, fill = "#bd002666", color = "#bd002666") + |
|||
geom_sf_text(data = york_towns, aes(label = id), family = font_es_bold, size = 4.25, color="white") + |
|||
geom_sf_text(data = york_towns, aes(label = id), family = font_es_light, size = 4) + |
|||
coord_sf(datum = NA, xlim=c(-70.84655, -70.577334), ylim=c(43.061743, 43.216308)) + |
|||
labs( |
|||
x = NULL, y = NULL |
|||
) + |
|||
theme_ipsum_es(grid="") -> gg2 |
|||
|
|||
gg + gg1 + gg2 + plot_layout(ncol = 3) |
|||
|
|||
|
|||
|
@ -0,0 +1,97 @@ |
|||
library(sf) |
|||
library(tigris) |
|||
library(patchwork) |
|||
library(hrbrthemes) |
|||
library(tidyverse) |
|||
|
|||
# https://www.epa.gov/smartgrowth/smart-location-mapping#walkability |
|||
# https://catalog.data.gov/dataset/walkability-index |
|||
|
|||
st_read(here::here("data/me-counties.json")) %>% |
|||
st_set_crs(4326) %>% |
|||
st_transform("+proj=longlat +datum=WGS84 +no_defs") -> maine |
|||
|
|||
filter(maine, NAME == "York") -> york |
|||
|
|||
border <- st_union(maine) |
|||
|
|||
if (!all(file.exists(here::here("data", c("me-walkies.rds", "york-walkies.rds"))))) { |
|||
|
|||
walkies <- st_read("~/Desktop/WalkabilityIndex/Natl_WI.gdb/", "WalkabilityIndex") |
|||
|
|||
me_walkies <- st_intersection(walkies, border) |
|||
york_walkies <- st_intersection(me_walkies, york) |
|||
|
|||
saveRDS(me_walkies, here::here("data/me-walkies.rds")) |
|||
saveRDS(york_walkies, here::here("data/york-walkies.rds")) |
|||
|
|||
} |
|||
|
|||
me_walkies <- readRDS(here::here("data/me-walkies.rds")) |
|||
york_walkies <- readRDS(here::here("data/york-walkies.rds")) |
|||
|
|||
rivers <- linear_water(state = "ME", "York", class="sf") |
|||
water <- area_water(state = "ME", "York", class = "sf") |
|||
rd <- roads(state = "ME", "York", class = "sf") |
|||
|
|||
st_read(here::here("data/me-topo.geojson")) %>% |
|||
st_set_crs(4326) %>% |
|||
st_transform("+proj=longlat +datum=WGS84 +no_defs") -> towns |
|||
|
|||
st_intersection(st_buffer(towns, 0), york) %>% |
|||
mutate( |
|||
id = as.character(id), |
|||
id = case_when( |
|||
id == "NorthBerick" ~ "North\nBerwick", |
|||
id == "SouthBerick" ~ "South\nBerwick", |
|||
id == "Sandford" ~ "Sanford", |
|||
id == "SacoCty" ~ "Saco", |
|||
id == "BiddefordCty" ~ "Biddeford", |
|||
id == "OldOrchardBeach" ~ "Old Orchard\nBeach", |
|||
TRUE ~ id |
|||
) |
|||
) -> york_towns |
|||
|
|||
ggplot() + |
|||
geom_sf(data = me_walkies, color = "white", size = 0.125, aes(fill = WalkIndex)) + |
|||
scale_fill_viridis_c( |
|||
direction = -1, limits = c(0,20), name = "Walkability Index\n", |
|||
breaks = seq(0, 20, 5), labels = c("0 (Nigh impassable)", 5, 10, 15, "20 (Very walkable)") |
|||
) + |
|||
coord_sf(crs=albersusa::us_laea_proj, datum=NA) + |
|||
labs( |
|||
x = NULL, y = NULL, |
|||
title = "Walkability (At The Macro-Level) In Maine", |
|||
caption = "Data source: <catalog.data.gov/dataset/walkability-index>; {tigris}\n#30DayMapChallenge • <git.rud.is/hrbrmstr/y2019-30daymapchallenge>" |
|||
) + |
|||
theme_ipsum_es(grid="") + |
|||
theme(legend.position = c(0.11, 0.5)) + |
|||
theme(legend.title = element_text(family = font_es_bold, hjust = 0.5)) + |
|||
theme(legend.box.background = element_rect(color = "#2b2b2b", fill = "white")) |
|||
|
|||
|
|||
ggplot() + |
|||
geom_sf(data = york_walkies, aes(fill = WalkIndex), color = "white", size = 0.1) + |
|||
geom_sf(data = water, fill = "#8cb6d3", color = "#8cb6d3") + |
|||
geom_sf(data = rivers, size = 0.1, color = "#8cb6d3") + |
|||
geom_sf(data = rd, size = 0.1, color = "#4c4c4c") + |
|||
geom_sf_label( |
|||
data = york_towns, aes(label = id), family = font_es_light, size = 3, lineheight = 0.875, |
|||
label.padding = unit(0.05, "lines"), label.size = 0, fill = "#ffffff33" |
|||
) + |
|||
scale_fill_viridis_c( |
|||
direction = -1, limits = c(0,20), name = "Walkability Index\n", |
|||
breaks = seq(0, 20, 5), labels = c("0 (Nigh impassable)", 5, 10, 15, "20 (Very walkable)") |
|||
) + |
|||
coord_sf(crs=albersusa::us_laea_proj, datum=NA) + |
|||
labs( |
|||
x = NULL, y = NULL, |
|||
title = "Walkability In My Surrounding Habitat (York County, Maine)", |
|||
subtitle = "Only a few areas are truly 'walkable', most in coastal communities.", |
|||
caption = "Data source: <catalog.data.gov/dataset/walkability-index>; {tigris}\n#30DayMapChallenge • <git.rud.is/hrbrmstr/y2019-30daymapchallenge>" |
|||
) + |
|||
theme_ipsum_es(grid="") + |
|||
theme(legend.position = c(0.11, 0.5)) + |
|||
theme(legend.title = element_text(family = font_es_bold, hjust = 0.5)) + |
|||
theme(legend.box.background = element_rect(color = "#2b2b2b", fill = "white")) |
|||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue