-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate1a.Rmd
More file actions
164 lines (136 loc) · 6.15 KB
/
template1a.Rmd
File metadata and controls
164 lines (136 loc) · 6.15 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
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
---
title: "DC Lead Pipe Replacement"
output:
flexdashboard::flex_dashboard:
theme: bootstrap
logo: "etc/logo.svg"
favicon: "etc/icon.png"
navbar:
- { title: "Map", href: "#map", align: left }
- { title: "About", href: "#about", align: left}
- { title: "Data Download", icon: "fa-download", href: "https://www.dcwater.com/sites/default/files/cleanrivers/service-line.csv", align: left }
- { title: "Source Code", icon: "fa-github", href: "https://github.com/WaterDataLab/lead", align: left, target: "_blank"}
orientation: rows
vertical_layout: fill
css: "etc/style.css"
---
<script>
$('.navbar-logo').wrap('<a href="https://www.watergrid.io" target="_blank">');
</script>
```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
library(tidyverse)
library(sf)
library(leafgl)
# colors
pal <- rcartocolor::carto_pal(12, "Bold")
# DC lead data
url <- "https://www.dcwater.com/sites/default/files/cleanrivers/service-line.csv"
# webgl
df <- read_csv(url) %>%
janitor::clean_names()
# clean up
df <- df %>%
select(premise_address, public_service_material,
private_service_material, longitude, latitude) %>%
st_as_sf(coords = c("longitude", "latitude"), crs = 4326)
# color points based on lead
lead <- c("Lead_brass", "Iron with lead", "Lead and copper",
"Lead", "LEAD AND COPPER", "LEAD\n",
"Galvanized iron with lead")
# add colors depending on if lead is present
df <- df %>%
mutate(
public_lead = ifelse(public_service_material %in% lead,
"grey50", "green"),
public_lead = ifelse(public_service_material == "No information",
"white", public_lead),
private_lead = ifelse(private_service_material %in% lead,
"grey50", "green"),
private_lead = ifelse(private_service_material == "No information",
"white", private_lead),
popup = paste0(
"<b>", premise_address, "</b><br>",
"<b>Public: </b>", public_service_material, "<br>",
"<b>Private: </b>", private_service_material)
)
```
Map {.hidden}
=====================================
```{r}
# make leaflet
leaflet() %>%
# 4 basemaps
addProviderTiles(provider = providers$CartoDB.Positron, group = "Light") %>%
addProviderTiles(provider = providers$CartoDB.DarkMatter, group = "Dark") %>%
addProviderTiles(provider = providers$OpenStreetMap, group = "Street") %>%
addProviderTiles(provider = providers$Esri.WorldImagery, group = "World") %>%
# public lead points
addGlPoints(
data = filter(df, public_lead == "grey50"),
fillColor = "public_lead",
fillOpacity = 1,
radius = 20,
group = "Lead"
) %>%
# public no lead points
addGlPoints(
data = filter(df, public_lead != "grey50"),
fillColor = "public_lead",
fillOpacity = 1,
radius = 20,
group = "No lead"
) %>%
# private lead points
addGlPoints(
data = filter(df, private_lead == "grey50"),
fillColor = "private_lead",
fillOpacity = 1,
radius = 10,
popup = "popup",
group = "Lead"
) %>%
# private no lead points
addGlPoints(
data = filter(df, private_lead != "grey50"),
fillColor = "private_lead",
fillOpacity = 1,
radius = 10,
popup = "popup",
group = "No lead"
) %>%
flyTo(lng = mean(st_coordinates(df)[, 1]),
lat = mean(st_coordinates(df)[, 2]), zoom = 12) %>%
leaflet.extras::suspendScroll() %>%
leaflegend::addLegendImage(
images = "legend.png",
labels = "",
title = htmltools::tags$div(
"Legend",
style = "font-size: 16px; text-align: center; margin-bottom: 5px;"),
position = "topright",
orientation = "vertical",
height = 165, width = 180) %>%
addLayersControl(
overlayGroups = c("Lead", "Lead", "No lead"),
baseGroups = c("Light", "Dark", "Street", "World"),
options = layersControlOptions(collapsed = FALSE),
position = "topright"
)
```
About {.hidden}
=====================================
### **Why replace lead pipes?**
<iframe width="100%" height="285" src="https://www.youtube.com/embed/6DJDGtM_d5Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" data-external="1"></iframe>
#### **History**
DC Water has historic data for the public portion of the water service line from plumbing records, service installation, and some maintenance activity that was reported to DC Water or another utility agency. Where DC Water has verified the pipe material by test pit or visual observation during a public space and/or private property service line replacement, the data source will be shown as "excavation" and is accurate as of the given inspection date. All other information is based upon historic records, but has not been confirmed. The map reflects the information DC Water has available for each active customer in the District.
### **Disclaimer**
The maps provided by the District of Columbia Water and Sewer Authority (“D.C. Water”) are based on historical data, information directly provided by customers, and in some cases, information acquired during physical inspections. DC Water does not guarantee the accuracy of these records and maps, which shall be used for the sole purpose of providing property owners and residents with DC Water’s best available data regarding their private water services, and not for any commercial, legal or other use. These records will be updated constantly as D.C. Water gathers additional information. D.C. Water requests that customers provide to it records of any service line replacements performed by property owners. D.C. Water reserves the right to alter, amend or terminate at any time the display of these maps and records.
#### **More information**
- <a href="https://www.dcwater.com/faq-page/74" target="_blank">Service Lines - Fact Sheet</a>
- <a href="https://www.dcwater.com/Lead" target="_blank">DC Water Lead information</a>
### **Contact**
* _General inquiries_: 202-787-2000
* _Email_: customer.service@dcwater.com
* _Twitter_: <a href="https://twitter.com/dcwater" target="_blank">@ dcwater</a>