-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.Rmd
244 lines (195 loc) · 9.95 KB
/
index.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# How A Booming Population And Climate Change Made California’s Wildfires Worse Than Ever
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(out.width="900px", dpi=300)
```
Data and [R](https://www.r-project.org/) code to reproduce graphics in this [Jul. 28, 2018 BuzzFeed News post](https://www.buzzfeednews.com/article/peteraldhous/california-wildfires-people-climate) on wildfires in California. Supporting files are in [this GitHub repository](https://github.com/BuzzFeedNews/2018-07-wildfire-trends).
### Data
To analyze trends in California wildfires, we used the California Department of Forestry and Fire Protection (Cal Fire) [Fire Perimeters Geodatabase](http://frap.fire.ca.gov/data/frapgisdata-sw-fireperimeters_download), which records forest fires of 10 acres or greater, brush fires of 30 acres and greater, and grass fires of 300 acres or greater. The file `calfire_frap.csv` is derived from this database.
To put California's wildfires in a national context, we used the US Forest Service's [Spatial Wildfire Occurrence Data For The United States](https://www.fs.usda.gov/rds/archive/Product/RDS-2013-0009.4/), which records wildfires across the nation from 1992 to 2015. This data is in a series of CSV files in the `us_fires` folder.
Cal Fire's data on buildings destroyed by wildfires per year is in the file `calfire_damage.csv`.
### Setting up
Required packages and color palette for major fire causes (human, natural, unknown).
```{r, results="hide", warning=FALSE, message=FALSE}
# load required packages
library(dplyr)
library(readr)
library(ggplot2)
library(ggthemes)
library(scales)
library(maps)
library(mapproj)
# color palette for major fire causes
cause_pal <- c("#ffff00","#d397fc","#ffffff")
```
### Big fires have gotten more common
To plot fires by date, we used the Cal Fire alarm date.
```{r, results="hide", warning=FALSE, message=FALSE}
# load and process data
calfire <- read_csv("data/calfire_frap.csv") %>%
mutate(cause2 = case_when(cause == 1 | cause == 17 ~ "Natural",
cause == 14 | is.na(cause) ~ "Unknown",
cause != 1 | cause != 14 | cause != 17 ~ "Human"),
plot_date = as.Date(format(alarm_date,"2017-%m-%d")))
# plot template
plot_template <- ggplot(calfire, aes(y=year_)) +
geom_hline(yintercept = seq(1950, 2017, by = 1), color = "gray", size = 0.05) +
scale_size_area(max_size = 10, guide = FALSE) +
scale_x_date(date_breaks = "months", date_labels = "%b") +
scale_y_reverse(limits = c(2017,1950), breaks = c(2010,1990,1970,1950)) +
xlab("") +
ylab("") +
theme_hc(bgcolor = "darkunica", base_size = 20, base_family = "ProximaNova-Semibold") +
theme(axis.text = element_text(color = "#ffffff"))
plot_template +
geom_point(aes(size=gis_acres, x=plot_date), color="#ffa500", alpha=0.7)
```
### But the pattern is different for natural and human-started fires
```{r, results="hide", warning=FALSE, message=FALSE}
# plot template
cause_plot <- plot_template +
scale_color_manual(values = cause_pal, guide = FALSE) +
geom_point(aes(size = gis_acres, x = plot_date, color = cause2, alpha = cause2))
# plot natural fires
opacity <- c(0,0.7,0)
cause_plot +
scale_alpha_manual(values = opacity, guide = FALSE) +
ggtitle("Natural") + theme(plot.title = element_text(color = "#d397fc", size = 16, hjust = 0.5))
# plot human-caused fires
opacity <- c(0.7,0,0)
cause_plot +
scale_alpha_manual(values = opacity, guide = FALSE) +
ggtitle("Human") + theme(plot.title = element_text(color = "#ffff00", size = 16, hjust = 0.5))
# plot unknown cause fires
opacity <- c(0,0,0.7)
cause_plot +
scale_alpha_manual(values = opacity, guide = FALSE) +
ggtitle("Unknown") + theme(plot.title = element_text(color = "#ffffff", size = 16, hjust = 0.5))
```
### California’s problems with human-caused fires set it apart from most of the West
```{r}
# load data
files <- list.files("data/us_fires")
us_fires <- data_frame()
for (f in files) {
tmp <- read_csv(paste0("data/us_fires/",f), col_types = cols(
.default = col_character(),
stat_cause_code = col_double(),
cont_date = col_datetime(format = ""),
discovery_date = col_datetime(format = ""),
cont_doy = col_integer(),
cont_time = col_integer(),
fire_size = col_double(),
latitude = col_double(),
longitude = col_double()
))
us_fires <- bind_rows(us_fires,tmp)
}
rm(tmp)
# assign fires to main causes
us_fires <- us_fires %>%
mutate(cause = case_when(stat_cause_code == 1 ~ "Natural",
stat_cause_code == 13 | is.na(stat_cause_code) ~ "Unknown",
stat_cause_code >= 2 | stat_cause_code <= 12 ~ "Human"),
date = as.Date(case_when(is.na(discovery_date) ~ cont_date,
!is.na(discovery_date) ~ discovery_date)))
```
We assigned the fires to a grid with a resolution of half a degree latitude and longitude and then calculated:
* the total area burned per grid cell over the entire period;
* the area burned in natural fires and in those started by human activities or infrastructure;
* the percentage burned in human-caused fires, where the cause was known.
(In these calculations, repeated burns of the same area are added together.)
```{r, results="hide", warning=FALSE, message=FALSE}
# assign fires to a grid with half-degree latitude and longitude resolution
cells <- function(xy, origin = c(0,0), cellsize = c(0.5,0.5)) {
t(apply(xy, 1, function(z) cellsize/2+origin+cellsize*(floor((z - origin)/cellsize))))
}
centroids <- cells(cbind(us_fires$latitude, us_fires$longitude))
us_fires$x <- centroids[, 2]
us_fires$y <- centroids[, 1]
us_fires$cell <- paste(us_fires$x, us_fires$y)
# total area burned per cell
grid_us_fires_total <- us_fires %>%
group_by(x,y,cell) %>%
summarize(total_acres = sum(fire_size))
# area burned per cell for natural fires
grid_us_fires_natural <- us_fires %>%
filter(cause == "Natural") %>%
group_by(cause,x,y,cell) %>%
summarize(natural_acres = sum(fire_size)) %>%
ungroup() %>%
select(-cause)
# area burned per cell for human-caused fires
grid_us_fires_human <- us_fires %>%
filter(cause == "Human") %>%
group_by(cause,x,y,cell) %>%
summarize(human_acres = sum(fire_size)) %>%
ungroup() %>%
select(-cause)
# combine into a single data frame and replace NAs with zeros
grid_us_fires <- left_join(grid_us_fires_total, grid_us_fires_natural) %>%
left_join(grid_us_fires_human)
grid_us_fires[is.na(grid_us_fires)] <- 0
# calculate % acres burned in fires cause by humans (where cause is known)
grid_us_fires <- grid_us_fires %>%
mutate(pc_human_acres = human_acres/(human_acres+natural_acres)*100)
# for cells in which all fires are of unknown cause, assign a value of 50%
grid_us_fires$pc_human_acres[is.nan(grid_us_fires$pc_human_acres)] <- 50
```
We then filtered the data to show only the continental US, removed grid cells with an average of less than 50 acres burned per year, and plotted on a map. The circles for each grid cell were scaled by the total area burned, and colored according to the percentage of that area burned in fires started by human activities or infrastructure.
```{r, results="hide", warning=FALSE, message=FALSE}
# filter for continental US and remove cells with less than 50 acres burned per year
grid_us_fires <- grid_us_fires %>%
filter(x < -65 & x > -125 & y > 24 & y < 50 & total_acres > 1200)
# plot
ggplot(grid_us_fires) +
geom_point(aes(x = x, y = y, size = total_acres, color = pc_human_acres), alpha = 0.7) +
borders("state", xlim = c(-125, -65), ylim = c(24, 50), size = 0.2) +
scale_size_area(max_size = 4, guide = FALSE) +
scale_color_gradient2(low = "#950fdf", mid = "#ffffff", high = "#ffff00", midpoint = 50, guide = "legend", name = "% burned in human-caused fires") +
coord_map("mercator") +
theme_map(base_size = 16, base_family = "ProximaNova-Semibold") +
theme(axis.line = element_blank(),axis.text.x = element_blank(),
axis.text.y = element_blank(),axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_rect(fill = "#2c2c2d"),
legend.background = element_rect(fill = "#2c2c2d"),
legend.position = "bottom",
legend.direction = "horizontal",
legend.justification = "center",
legend.text = element_text(color = "#ffffff"),
legend.title = element_text(color = "#ffffff"),
legend.key = element_rect(fill = "#2c2c2d")) +
guides(color = guide_legend(title.position="top", title.hjust = 0.5))
```
### If California can’t reduce the number of catastrophic fires, last year’s record season may become the new normal.
These charts show how 2017 was the most devasting year for wildfires in California on record. The first shows the total area burned per year, recorded in Cal Fire's Fire Perimeters Geodatabase.
```{r, results="hide", warning=FALSE, message=FALSE}
# calculate total acres burned per year
acres_year <- calfire %>%
group_by(year_) %>%
summarize(acres = sum(gis_acres, na.rm=T))
# plot
ggplot(acres_year, aes(x = year_, y = acres/10^6)) +
geom_bar(stat = "identity", fill = "#ffa500", color = "#ffa500", size = 0, alpha = 0.7) +
ylab("Acres burned (millions)") +
xlab("") +
scale_x_continuous(breaks = c(1950,1970,1990,2010)) +
theme_hc(bgcolor = "darkunica", base_size = 20, base_family = "ProximaNova-Semibold") +
theme(axis.text = element_text(color = "#ffffff"))
```
The second shows the number of buildings destroyed per year from 1989 to 2017, from Cal Fire data.
```{r, results="hide", warning=FALSE, message=FALSE}
# load data
damage <- read_csv("data/calfire_damage.csv")
# plot
ggplot(damage, aes(x = year, y = structures)) +
geom_bar(stat = "identity", fill = "#ffa500", color = "#ffa500", size = 0, alpha = 0.7) +
scale_y_continuous(labels = comma) +
xlab("") +
ylab("Structures destroyed") +
theme_hc(bgcolor = "darkunica", base_size = 20, base_family = "ProximaNova-Semibold") +
theme(axis.text = element_text(color = "#ffffff"))
```