-
Notifications
You must be signed in to change notification settings - Fork 1
/
tx-spills-central.Rmd
169 lines (143 loc) · 5.07 KB
/
tx-spills-central.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
---
title: "Texas produced water spills, analysis of central Railroad Commission spill logs"
output:
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE)
```
### Setting up
```{r}
# load required packages
library(tidyverse)
library(scales)
library(DT)
# load data on produced water spills, 2013-2022 from central spill logs
tx_spills_central_prod_water <- read_csv("data/central_cleaned.csv")
```
### Total produced water spilled
```{r}
tx_spills_central_prod_water %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE))) %>%
mutate_all(., prettyNum, big.mark = ",") %>%
datatable(colnames = c("Spills", "Gallons released", "Gallons recovered"))
```
### Spills by year
```{r}
spills_year <- tx_spills_central_prod_water %>%
group_by(year = year(date_of_spill_edit)) %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE)))
spills_year %>%
mutate_at(c(2:4), prettyNum, big.mark = ",") %>%
datatable(colnames = c("Year", "Spills", "Gallons released", "Gallons recovered"))
```
```{r}
ggplot(spills_year, aes(x=year, y=released)) +
geom_col(fill = "red") +
geom_hline(yintercept = 0, linewidth = 0.3) +
scale_x_continuous(breaks = c(2014,2016,2018,2020,2022)) +
scale_y_continuous(labels = comma) +
xlab("") +
ylab("") +
theme_minimal() +
ggtitle("Gallons of produced water spilled, statewide by year") +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
plot.title.position = "plot")
```
### Spills by Railroad Commission district
```{r}
spills_district <- tx_spills_central_prod_water %>%
group_by(district_edit) %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE))) %>%
arrange(-released)
spills_district %>%
mutate_at(c(2:4), prettyNum, big.mark = ",") %>%
datatable(colnames = c("District", "Spills", "Gallons released", "Gallons recovered"))
```
```{r}
ggplot(spills_district, aes(x=reorder(district_edit,released), y=released)) +
geom_col(fill = "red") +
geom_hline(yintercept = 0, linewidth = 0.3) +
scale_y_continuous(labels = comma) +
xlab("") +
ylab("") +
theme_minimal() +
ggtitle("Gallons of produced water spilled, by district") +
theme(panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
plot.title.position = "plot") +
coord_flip()
```
### Spills by county
```{r}
spills_county <- tx_spills_central_prod_water %>%
group_by(county_edit) %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE))) %>%
arrange(-released)
spills_county %>%
mutate_at(c(2:4), prettyNum, big.mark = ",") %>%
datatable(colnames = c("County", "Spills", "Gallons released", "Gallons recovered"))
```
```{r}
spills_county_top10 <- spills_county %>%
slice_max(released, n = 10)
ggplot(spills_county_top10, aes(x=reorder(county_edit,released), y=released)) +
geom_col(fill = "red") +
geom_hline(yintercept = 0, linewidth = 0.3) +
scale_y_continuous(labels = comma) +
xlab("") +
ylab("") +
theme_minimal() +
ggtitle("Gallons of produced water spilled, top 10 counties") +
theme(panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
plot.title.position = "plot") +
coord_flip()
```
### Spills by operator
```{r}
spills_operator <- tx_spills_central_prod_water %>%
group_by(operator_edit) %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE))) %>%
arrange(-released)
spills_operator %>%
mutate_at(c(2:4), prettyNum, big.mark = ",") %>%
datatable(colnames = c("Operator", "Spills", "Gallons released", "Gallons recovered"))
```
```{r}
spills_operator_top10 <- spills_operator %>%
slice_max(released, n = 10)
ggplot(spills_operator_top10, aes(x=reorder(operator_edit,released), y=released)) +
geom_col(fill = "red") +
geom_hline(yintercept = 0, linewidth = 0.3) +
scale_y_continuous(labels = comma) +
xlab("") +
ylab("") +
theme_minimal() +
ggtitle("Gallons of produced water spilled, top 10 operators") +
theme(panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
plot.title.position = "plot") +
coord_flip()
```
### Total spilled on water
```{r}
tx_spills_central_prod_water %>%
filter(spill_on_water_edit == "YES") %>%
summarize(spills = n(),
released = round(sum(release_prod_water_edit, na.rm = TRUE)),
recovered = round(sum(recovery_prod_water_edit, na.rm = TRUE))) %>%
mutate_all(., prettyNum, big.mark = ",") %>%
datatable(colnames = c("Spills", "Gallons released", "Gallons recovered"))
```