Last active
November 18, 2017 00:48
-
-
Save tiernanmartin/51d34a1195c6d10940825ed5db28ce34 to your computer and use it in GitHub Desktop.
use Seattle Development Capacity to show impact of DADU policy thresholds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SETUP ---- | |
library(tidyverse) | |
library(treemapify) | |
library(RSocrata) | |
library(snakecase) | |
library(forcats) | |
library(waffle) | |
library(rcartocolor) | |
# DATA ---- | |
d <- read.socrata("https://data.seattle.gov/resource/unmu-zvzk.csv") %>% | |
rename_all(to_screaming_snake_case) | |
data <- | |
d %>% | |
filter(CLASS %in% "SF") %>% | |
filter(!RESSTAT %in% "MIO") %>% | |
filter(LAND_SQFT >= 3200) %>% | |
mutate(MAX_LOT_CVRG = case_when( | |
ZONELUT %in% c("SF 5000", "SF 7200","SF 9600") && LAND_SQFT < 5000 ~ 1000 + .15*LAND_SQFT, | |
ZONELUT %in% c("SF 5000", "SF 7200","SF 9600") && LAND_SQFT >= 5000 ~ .35*LAND_SQFT, | |
ZONELUT %in% "RSL" ~ as.double(LAND_SQFT), | |
TRUE ~ NA_real_ | |
)) %>% | |
mutate(AVAIL_SF = MAX_LOT_CVRG - BLDG_RES_GRSSQF, | |
BACKYARD_EST_SF = .75*(LAND_SQFT - BLDG_RES_GRSSQF)) %>% | |
filter(AVAIL_SF > 250, | |
.6*BACKYARD_EST_SF > 250) %>% | |
mutate_if(is_double,as.integer) %>% | |
select(PIN, | |
PROP_NAME, | |
ZONELUT, | |
CLASS, | |
RESSTAT, | |
LAND_SQFT, | |
PARCEL_DEV_SQFT, | |
BLDG_RES_GRSSQF, | |
MAX_LOT_CVRG, | |
AVAIL_SF, | |
BACKYARD_EST_SF) | |
data_sum <- | |
data %>% | |
mutate(GT_8000_LGL = PARCEL_DEV_SQFT>=8000, | |
GT_8000_CHR = if_else(GT_8000_LGL,"8000sqft or Larger", "Less than 8000sqft"), | |
GT_8000_FCT = fct_infreq(GT_8000_CHR, TRUE) %>% fct_rev, | |
ZONELUT_FCT = fct_infreq(ZONELUT, TRUE) %>% fct_rev, | |
ZONELUT_FCT_SIZE = if_else(GT_8000_LGL, | |
str_c(ZONELUT,"GT_8000",sep = "_"), | |
str_c(ZONELUT,"LT_8000",sep = "_")), | |
ZONELUT_FCT_SIZE = str_replace_all(ZONELUT_FCT_SIZE, "\\s","_")) %>% | |
mutate(ZONELUT_FCT_SIZE = factor(ZONELUT_FCT_SIZE, | |
levels= c( | |
"SF_5000_GT_8000", | |
"SF_7200_GT_8000", | |
"SF_9600_GT_8000", | |
"RSL_GT_8000", | |
"SF_5000_LT_8000", | |
"SF_7200_LT_8000", | |
"SF_9600_LT_8000", | |
"RSL_LT_8000"), | |
ordered = TRUE) %>% fct_rev) %>% | |
{bind_rows(., | |
filter(.,GT_8000_LGL), | |
.id = "ID")} %>% | |
group_by(ID) %>% | |
nest %>% | |
transmute(GROUP = if_else(ID %in% "1","ALL","GT_8000"), | |
DATA = data) %>% | |
unnest %>% | |
group_by(GROUP,ZONELUT_FCT_SIZE) %>% | |
summarise(PARCEL_DEV_SQFT = sum(PARCEL_DEV_SQFT), | |
N = n()) %>% | |
arrange(GROUP) | |
d_waffle <- | |
data_sum %>% | |
transmute(ZONELUT_FCT_SIZE, | |
N = N *1e-2) %>% | |
nest %>% | |
transpose %>% | |
map(2) | |
d_w1 <- d_waffle[[1]] | |
d_w2 <- | |
d_w1 %>% mutate(N = if_else(str_detect(as.character(ZONELUT_FCT_SIZE),"LT"),0,N)) | |
cols <- carto_pal(n = 7,"Geyser")[c(2:5)] | |
cols_rep <- rep(cols,2) | |
w1 <- waffle(d_w1, rows = 10,size = 2,legend_pos="none", reverse = TRUE,colors = cols_rep) | |
w2 <- waffle(d_w2, rows = 10,size = 2,pad = 29, legend_pos="bottom", reverse = TRUE, colors = cols_rep) | |
iron(w1,w2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment