-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNYCCAS Interactive Map.Rmd
186 lines (158 loc) · 6.8 KB
/
NYCCAS Interactive Map.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
---
title: "NYCCAS Map with NYSDOT Sites"
date: "2024-05-06"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, echo=FALSE, message=FALSE, warning=FALSE, error=FALSE, include=FALSE, result = 'hide'}
library(dplyr)
library(leaflet)
library(leaflegend)
library(htmlwidgets)
library(sf)
library(sp)
library(readxl)
library(htmltools)
library(jsonlite)
library(data.table)
library(tidyr)
library(readr)
options(digits = 10)
## Year 16 NYCCAS sites
nyccas_sites <- read_xlsx("Year16_FallSeason_Sites.xlsx", sheet = "Address")
nyccas_sites_y16 <- read_xlsx("Year16_FallSeason_Sites.xlsx", sheet = "Fall")
nyccas_intsites <- nyccas_sites %>%
filter(site_id %in% nyccas_sites_y16$SiteID |
Core_EJ == "Reference") %>%
mutate(cbdtp_extra = ifelse(site_id %in% c("12441", "8555", "7974", "4664-EJ", "12449", "11532", "7717"), "Yes", "No")) %>%
## crs code = EPSG code for NAD83 CRS
st_as_sf(coords = c("longitude", "latitude"), crs = 4269)
nyccas_intsites_aug <- nyccas_intsites %>%
filter(cbdtp_extra == "Yes")
## Proposed new RT PM2.5 sites
newRTPM <- read_xlsx("new_rt_sites_proposed.xlsx")
## Regular RT PM2.5 sites
regRTPM <- read_csv("MasterSiteMonitorList.csv")
RTPM <- regRTPM %>%
select(latitude = Lat,
longitude = Long,
`Street Segment` = Location,
Zone = Short_Loc) %>%
bind_rows(newRTPM) %>%
distinct(Zone, .keep_all = T) %>%
## Include only current and planned sites
filter(Zone %in% c("Broadway/35th St",
"Cross Bronx Expy",
"Hunts Point",
"Manhattan Bridge",
"Midtown-DOT",
"Queens College",
"Queensboro Bridge",
"Williamsburg Bridge",
"Glendale",
"BQE",
"FDR",
"TME",
"RFK Bridge",
"SI Expressway",
"Van Wyck Control")) %>%
mutate(
Zone = case_when(
Zone == "TME" ~ "Trans-Manhattan",
Zone == "RFK Bridge" ~ "Deegan",
TRUE~Zone),
Type = ifelse(Zone %in% c("Cross Bronx Expy",
"FDR",
"BQE",
"Trans-Manhattan",
"Deegan",
"SI Expressway",
"Van Wyck Control"), "CBDTP RT", "NYCCAS Other RT"))
nyccas_RTsites <- RTPM %>%
## crs code = EPSG code for NAD83 CRS
st_as_sf(coords = c("longitude", "latitude"), crs = 4269)
```
```{r, echo=FALSE, message=FALSE, warning=FALSE, error=FALSE, include=FALSE, result = 'hide'}
## NYSDOT Short Count Locations
## Fall 2023 Short Count Locations
nysdot_F23 <- read_xlsx("NYSDOT_countsites_CBDTP_dft_v2_05-03-24.xlsx",
sheet = "fall2023_shortcount_locations")
## Other short count sites
nysdot_all <- read_xlsx("NYSDOT_countsites_CBDTP_dft_v2_05-03-24.xlsx",
sheet = "NYSDOT_counteraadt_and_truckpct")
nysdot_all_nyc <- nysdot_all %>%
filter(County %in% c("Bronx", "Kings", "New york", "Queens", "Richmond"))
nysdot_F23_sites <- nysdot_F23 %>%
filter(!is.na(Longitude)) %>%
st_as_sf(coords = c("Longitude", "Latitude"), crs = 4269)
nysdot_alNYC_sites <- nysdot_all_nyc %>%
filter(!is.na(Longitude)) %>%
st_as_sf(coords = c("Longitude", "Latitude"), crs = 4269)
```
```{r, echo=FALSE, warning=FALSE, message=FALSE, error=FALSE}
leaflet(width = 1000, height = 700) %>%
setView(-73.97937985, 40.71852252, zoom = 10) %>%
addProviderTiles(provider = "CartoDB") %>%
addCircleMarkers(data = nyccas_intsites,
radius = 7,
group = "NYCCAS Integrated",
popup = ~paste("<b>Site ID:</b></br>", htmlEscape(site_id)),
stroke = TRUE, # remove polygon borders
weight = 1,
color = "black",
fillColor = "gray",
fillOpacity = 0.8) %>%
addCircleMarkers(data = nyccas_intsites_aug,
radius = 5,
group = "CBDTP Expanded Integrated",
popup = ~paste("<b>Site ID:</b></br>", htmlEscape(site_id)),
stroke = TRUE, # remove polygon borders
weight = 1,
color = "black",
fillColor = "blue",
fillOpacity = 0.8) %>%
addCircleMarkers(data = nyccas_RTsites %>% filter(Type=="CBDTP RT"),
radius = 5,
group = "Real-time PM2.5 - CBDTP",
popup = ~paste("<b>Site ID:</b></br>", htmlEscape(Zone)),
stroke = TRUE, # remove polygon borders
weight = 1,
color = "black",
fillColor = "orange",
fillOpacity = 0.8) %>%
addCircleMarkers(data = nyccas_RTsites %>% filter(Type=="NYCCAS Other RT"),
radius = 5,
group = "Real-time PM2.5 - NYCCAS, Other",
popup = ~paste("<b>Site ID:</b></br>", htmlEscape(Zone)),
stroke = TRUE, # remove polygon borders
weight = 1,
color = "black",
fillColor = "brown",
fillOpacity = 0.8) %>%
addAwesomeMarkers(data = nysdot_F23_sites,
icon = awesomeIcons(icon = "car",
library = "fa",
iconColor = "black",
markerColor = "blue",
squareMarker = TRUE),
group = "Fall 2023 Short Counts for TBTA",
popup = ~paste("<b>Station ID:</b></br>", htmlEscape(`Station ID`))) %>%
addAwesomeMarkers(data = nysdot_alNYC_sites,
icon = awesomeIcons(icon = "car",
library = "fa",
iconColor = "black",
markerColor = "gray",
squareMarker = TRUE),
group = "All NYSDOT Short Counts",
popup = ~paste("<b>Station ID:</b></br>", htmlEscape(`Station ID`))) %>%
hideGroup("All NYSDOT Short Counts") %>%
addLayersControl(overlayGroups = c("NYCCAS Integrated",
"CBDTP Expanded Integrated",
"Real-time PM2.5 - CBDTP",
"Real-time PM2.5 - NYCCAS, Other",
"Fall 2023 Short Counts for TBTA",
"All NYSDOT Short Counts"),
options = layersControlOptions(collapsed = FALSE))
```