-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.qmd
110 lines (86 loc) · 3.18 KB
/
index.qmd
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
title: "Trends in home and lot size over time in Chapel Hill"
format:
html:
title-block-banner: true
toc: true
toc-location: left
toc-depth: 3
html-math-method: katex
code-fold: true
code-summary: "show the code"
code-overflow: wrap
code-tools: true
number-sections: true
theme:
dark: slate
light: flatly
fig-width: 9
fig-height: 6
editor: visual
---
## Introduction
Let's look at the trend in the lot size and home size of houses built in Chapel Hill over time.
## Get some data
We need: Year Built Structure Type, Parcel Size, and Floor area.
Let's pull in the Orange County parcel data, which tells us where parcels are and their area. It's available [here](ParcelsGDB.zip).
We also need the Orange County Address data, which has the year built, floor area. That's available [here](%22https://web.co.orange.nc.us/gisdownloads/addresses.zip%22).
Finally, we need the municipal boundaries to accurately capture which jurisdictions are relevant. That's available [here](%22https://web.co.orange.nc.us/gisdownloads/city.zip%22).
```{r, output=FALSE, echo=FALSE, message=FALSE, warning=FALSE}
library(tidyverse)
library(Hmisc)
library(mdbr)
library(knitr)
library(sf)
library(gganimate)
```
```{r, eval = FALSE}
download.file("https://web.co.orange.nc.us/gisdownloads/ParcelsGDB.zip", destfile = "ParcelsGDB.zip")
unzip("ParcelsGDB.zip")
download.file("https://web.co.orange.nc.us/gisdownloads/addresses.zip", destfile = "addresses.zip")
unzip("addresses.zip")
download.file("https://web.co.orange.nc.us/gisdownloads/city.zip", destfile = "city.zip")
unzip("city.zip")
```
## Read in the data!
And get only the Chapel Hill boundary.
```{r}
data <- read_mdb("ParcelsGDB.mdb", table="PARCELVIEW")
addr <- read_sf("addresses.shp")
city <- read_sf("city.shp")
ch <- city %>% filter(CITYCODE == "CH") %>% st_union() %>% st_as_sf()
```
## Summarise the data
First, we filter the addresses to only single family-type residences.
```{r, results="asis"}
addr <- addr %>% filter(LBCSSubCod < 1160 & LBCSSubCod >0)
addr <- addr[ch,]
#mapview::mapview(addr,zcol="LBCSDesc")
parcels <- sf::read_sf("All_Parcels.geojson")
duplex_footprint <- 2774
d <- right_join(parcels,st_drop_geometry(addr),by="PIN") %>%
filter(LBCSDesc %in% c("Res-Single Family", "Res-MH-SW", "Res-MH-DW-TW")) %>%
filter(OwnerAddress!="PROPERTY OFFICE UNC") %>%
st_transform(2264) %>% st_make_valid() %>%
mutate(area_acr = as.numeric(st_area(.)/43560), area_ft2 = as.numeric(st_area(.))) %>%
filter(area_acr<5) %>%
mutate(plexable = case_when(area_ft2>=4*duplex_footprint ~ "yes", TRUE ~ "no"))
```
We then filter to only parcels in CH, and animate the plot.
```{r, results="asis"}
data2 <- data %>% filter(PIN %in% d$PIN)
gif <- data2 %>%
filter(FinArea < 6000 & YearBlt > 1900 & Shape_Area < 43560*2) %>%
arrange(desc(YearBlt)) %>%
ggplot(aes(x=Shape_Area/43560, y=FinArea, color=YearBlt)) +
geom_point(alpha=0.5) +
transition_time(YearBlt) +
labs(title = 'Year: {frame_time}') +
shadow_mark() +
scale_colour_viridis_b() +
xlab("Lot Size (Acres)") +
ylab("Unit sqft")
gif<-animate(gif, renderer=gifski_renderer())
anim_save("gig.gif",gif)
gif
```