forked from andrewmaclachlan/CASA0005mapmakinglivecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek5R.Rmd
More file actions
87 lines (63 loc) · 2.09 KB
/
week5R.Rmd
File metadata and controls
87 lines (63 loc) · 2.09 KB
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
---
title: "mapping"
author: "AMacLachlan"
date: "03/11/2021"
output: html_document
---
# Notes
bedroom is at ward - convert to borough
could also probably just use Local Area District Data
Hotel is points - summarise over borough
Airbnb is points - summarise over borough
```{r}
library(sf)
library(tmap)
library(tmaptools)
library(tidyverse)
library(here)
library(janitor)
```
```{r spatial data}
OSM <- st_read(here::here(
"greater-london-latest-free.shp",
"gis_osm_pois_a_free_1.shp")) %>%
st_transform(., 27700) %>%
#select hotels only
filter(fclass == 'hotel')
Londonborough <- st_read(here::here("statistical-gis-boundaries-london",
"statistical-gis-boundaries-london",
"ESRI",
"London_Borough_Excluding_MHW.shp"))%>%
st_transform(., 27700)
Londonward <- st_read(here::here("statistical-gis-boundaries-london",
"statistical-gis-boundaries-london",
"ESRI",
"London_Ward.shp"))
```
```{r Airbnb London}
Airbnb <- read_csv(here::here("listings.csv"))%>%
clean_names
Airbnbsf <- st_as_sf(Airbnb, coords = c("longitude", "latitude"),
crs = 4326)%>%
st_transform(., 27700)
Airbnb_within_London <- st_join(Londonborough, Airbnbsf, join = st_within)
```
```{r bedrooms}
beds <- read_csv((here::here("ward_bedrooms.csv")))%>%
clean_names()
Londonward_beds <- Londonward %>%
left_join(.,
beds,
by = c("GSS_CODE" = "geography_code"))%>%
group_by(LB_GSS_CD, BOROUGH )%>%
summarise(sum=sum(bedrooms_all_categories_number_of_bedrooms_measures_value, na.rm=TRUE))
```
```{r}
Airbnbsf_entire_home <- Airbnbsf %>%
filter(room_type == 'Entire home/apt' & availability_365 =='365')
Londonborough_info <- Londonborough %>%
st_join(., Airbnbsf_entire_home)%>%
add_count(GSS_CODE, name="hotels_in_borough")
st_join(Londonborough,.)%>%
add_count(GSS_CODE, name="hotels_in_borough")
```