-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path02_leaflet_helis.Rmd
224 lines (167 loc) · 6.33 KB
/
02_leaflet_helis.Rmd
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
title: "Analyzing flight paths with Leaflet"
author: "Andrew Ba Tran"
date: "6/23/2020"
output: html_document
---
```{r setup, warning=F, message=F}
library(tidyverse)
library(leaflet)
library(lubridate)
library(sf)
# Load processed geojson of data
points <- read_sf("data/heli_points.geojson")
# Adjust knots to miles per hour
points$speed <- points$speed * 1.15
points_dc <- points %>%
mutate(day=day(timestamp)) %>%
mutate(hour=hour(timestamp)) %>%
mutate(minute=minute(timestamp))
# filtering to June 1
points_dc1 <- points_dc %>%
filter(day==1)
# filtering to June 2 before 4 am
points_dc2 <- points_dc %>%
filter(day==2) %>%
filter(hour<4)
# joining June 1 and June 2
points_dc <- rbind(points_dc1, points_dc2)
# Set up popup window
points_dc$pop <- paste0("<b>", points_dc$code.x, "</b><br />",
points_dc$timestamp, "<br />Altitude: ",
points_dc$altitude_adjusted, "<br />Speed: ",
points_dc$speed)
# Some custom colors
cof <- colorFactor(c("#e41a1c", "#377eb8",
"#4daf4a", "#984ea3",
"#ff7f00", "#ffff33", "#a65628", "#f781bf",
"#6a3d9a"),
domain=c("A1DFFB", "AC9AB0",
"AC9BAE", "ADA908",
"ADD817", "AE1F45",
"A4D827", "AE1FE3", "AE0BED"))
```
## Flight paths of 9 aircraft
```{r map, warning=F, message=F, fig.width=9, fig.height=6}
# generating a leaflet map
m <- leaflet(points_dc) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
setView( -77.033768, 38.899123, zoom = 10) %>%
addCircleMarkers(popup=points_dc$pop, weight = 3, radius=2,
color=~cof(code.x), stroke = F, fillOpacity = 0.7)
m
```
```{r map1, warning=F, message=F, fig.width=9, fig.height=6}
points_dc <- points %>%
filter(code.x=="AE1F45" | code.x=="AE1FE3" | code.x=="AE0BED") %>%
mutate(day=day(timestamp)) %>%
mutate(hour=hour(timestamp)) %>%
mutate(minute=minute(timestamp)) #%>%
#filter(altitude_adjusted<=250) # if you want to focus only on the low altitude spots
# filtering to June 1
points_dc1 <- points_dc %>%
filter(day==1)
# filtering to June 2 before 4 am
points_dc2 <- points_dc %>%
filter(day==2) %>%
filter(hour<4)
# joining June 1 and June 2
points_dc <- rbind(points_dc1, points_dc2)
# Set up popup window
points_dc$pop <- paste0("<b>", points_dc$code.x, "</b><br />",
points_dc$timestamp, "<br />Altitude: ",
points_dc$altitude_adjusted, "<br />Speed: ",
points_dc$speed)
# Some custom colors
cof <- colorFactor(c("#ffff33", "#f781bf","#6a3d9a"),
domain=c("AE1F45", "AE1FE3", "AE0BED"))
```
## Lakotas and a Black Hawk
The Black Hawk data is too inaccurate but we're including it for context.
```{r map1_map, warning=F, message=F, fig.width=9, fig.height=6}
m <- leaflet(points_dc) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
setView( -77.033768, 38.899123, zoom = 12) %>%
addCircleMarkers(popup=points_dc$pop, weight = 3, radius=2,
color=~cof(code.x), stroke = F, fillOpacity = 0.7)
m
```
```{r map2, warning=F, message=F, fig.width=9, fig.height=6}
points_dc <- points %>%
filter(code.x=="AE1F45" | code.x=="AE1FE3") %>%
mutate(day=day(timestamp)) %>%
mutate(hour=hour(timestamp)) %>%
mutate(minute=minute(timestamp)) %>%
filter(altitude_adjusted<=250)
# filtering to June 1
points_dc1 <- points_dc %>%
filter(day==1)
# filtering to June 2 before 4 am
points_dc2 <- points_dc %>%
filter(day==2) %>%
filter(hour<4)
# joining June 1 and June 2
points_dc <- rbind(points_dc1, points_dc2)
# Set up popup window
points_dc$pop <- paste0("<b>", points_dc$code.x, "</b><br />",
points_dc$timestamp, "<br />Altitude: ",
points_dc$altitude_adjusted, "<br />Speed: ",
points_dc$speed)
# Some custom colors
cof <- colorFactor(c( "#f781bf","#6a3d9a"),
domain=c("AE1F45", "AE1FE3"))
```
## Two Lakotas when they flew lower than 250 feet
```{r map2_map, warning=F, message=F, fig.width=9, fig.height=6}
m <- leaflet(points_dc) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
setView( -77.033768, 38.899123, zoom = 13) %>%
addCircleMarkers(popup=points_dc$pop, weight = 3, radius=2,
color=~cof(code.x), stroke = F, fillOpacity = 0.7)
m
```
```{r map3, warning=F, message=F, fig.width=9, fig.height=6}
points_dc <- points %>%
filter(code.x=="AE1F45" | code.x=="AE1FE3" | code.x=="AE0BED") %>%
mutate(day=day(timestamp)) %>%
mutate(hour=hour(timestamp)) %>%
mutate(minute=minute(timestamp)) #%>%
#filter(altitude_adjusted<=250) # if you want to focus only on the low altitude spots
# filtering to June 1
points_dc1 <- points_dc %>%
filter(day==1) %>%
filter(hour==21) %>%
filter(minute>=50 & minute<=59)
# filtering to June 2 before 4 am
points_dc2 <- points_dc %>%
filter(day==1) %>%
filter(hour==22) %>%
filter(minute>=0 & minute<=10)
# joining June 1 and June 2
points_dc <- rbind(points_dc1, points_dc2)
# Set up popup window
points_dc$pop <- paste0("<b>", points_dc$code.x, "</b><br />",
points_dc$timestamp, "<br />Altitude: ",
points_dc$altitude_adjusted, "<br />Speed: ",
points_dc$speed)
# Some custom colors
cof <- colorFactor(c("#ffff33", "#f781bf","#6a3d9a"),
domain=c("AE1F45", "AE1FE3", "AE0BED"))
```
## Lakotas and a Black Hawk between 9:50 p.m. and 10:10 p.m.
The Black Hawk data is too inaccurate but we're including it for context.
```{r map3_map, warning=F, message=F, fig.width=9, fig.height=6}
m <- leaflet(points_dc) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
setView( -77.033768, 38.899123, zoom = 14) %>%
addCircleMarkers(popup=points_dc$pop, weight = 3, radius=2,
color=~cof(code.x), stroke = F, fillOpacity = 0.7)
m
```
## Altitude and time chart between 9:50 p.m. and 10:10 p.m.
```{r chart, warning=F, message=F, fig.width=9, fig.height=4}
ggplot(points_dc, aes(x=timestamp, y=altitude_adjusted, color=code.x)) +
geom_line() +
theme_minimal() +
labs(title="Approximate altitude of helicopters between 9:50 and 10:10 p.m.")
```