Code
library(terra)
library(sf)
library(tidyverse)
library(mapview) # Thanks, Jayden!
##### PART 1
fires <- vect("data/Lab5/Crown_fires84_24.shp")
crown <- vect("data/Lab5/Crown_MT.shp")
crown <- crown %>% project(fires) %>% st_as_sf()Fire size and severity
Data for this lab.
Download Lab5.zip from the course data archive on Zenodo and unzip it into a folder called data/Lab5/ in your project directory.
Fire plays a critical role in many terrestrial ecosystems on Earth, influencing both nature and society. This is especially true in Montana. We will be using several different kinds of data to explore patterns of total area burned, fire size, fire severity, and the relationships between these metrics and climate and topography in Montana’s Crown of the Continent.
We will be working with data from the Monitoring Trends in Burn Severity (MTBS) program (available at https://www.mtbs.gov/) and Sean Parks and colleagues (2025). The MTBS program uses remotely sensed data to estimate fire severity by looking at the difference between conditions before and after a fire. They classify data into 5 severity classes: unburned = dark green; low severity = light green, moderate severity = yellow; high severity = red; increased greenness = not shown below). The example below is from the Bridger Foothills fire in September 2020. Sean Parks and colleagues combined remotely sensed data and data collected in the field to estimate burn severity using information on the ecological impacts to forest (e.g., percent tree mortality) to develop their composite burn severity index.


Photo by Travis Belote.
For this lab, we will ask: (1) how might climate (drought) influence the total area burned in the Crown of the Continent? (2) what is the statistical distribution of fire sizes and what might this tell us about the causes and ecological and social consequences of fire management? (3) how does topography and vegetation influence fire severity?
In this lab, you will continue to learn how to manipulate spatial and tabular data in R.
In lab 5, we learned about potential evapotranspiration and actual evapotranspiration in relations to water deficit, net primary productivity, and the distribution of ecoregions. The same factors (energy and moisture) have been studied to develop indices of drought. For example, the Palmer Drought Severity Index (PDSI) has been used in multiple papers relating climate to fires. The PDSI combines precipitation, temperature (potential evapotranspiration, PET), and a simple soil moisture balance to estimate relative water surplus or deficit. It is a unitless index that typically ranges from about −5 (extreme drought) to +5 (extreme wet). We will investigate the relationship between annual and summer PDSI and total area burned.
First, we will bring in the fire perimeters for the Crown of the Continent, use a function in R to work with “strings” to make year a variable, and calculate total area burned each year using acres for each fire. We will then bring in two tables, join them to our year and area burned dataframe, and do some simple plotting to investigate relationships.
Notice that year is included in Ig_Date (ignition date) and includes the month and day. We want to create a new variable called “year” that only includes the year. To do this, we can use the str_sub from the stringr package (part of the tidyverse). After you make year a variable, plot the fires so that “year” is the fill of the fire perimeters.
Event_ID irwinID Incid_Name Incid_Type
1 MT4755711337219850629 <NA> CHARLOTTE PEAK Wildfire
2 MT4703511332619911012 <NA> GAME RANGE Wildfire
3 MT4763211227619931103 <NA> FREEZEOUT LAKE Wildfire
4 MT4736211449719991024 <NA> MCDONALD Wildfire
5 MT4868711403819990806 <NA> ANACONDA Wildland Fire Use
6 MT4771011352620010803 <NA> BERGSICKER COMPLEX (CANNON) Wildland Fire Use
Map_ID Map_Prog Asmnt_Type BurnBndAc BurnBndLat BurnBndLon Ig_Date
1 5018 MTBS Extended 5221 47.557 -113.372 1985-06-29
2 7394 MTBS Extended 5123 47.035 -113.326 1991-10-12
3 10005235 MTBS Initial 9793 47.669 -112.164 1993-11-03
4 10380 MTBS Initial 1174 47.362 -114.497 1999-10-24
5 10859 MTBS Extended 11452 48.687 -114.038 1999-08-06
6 12008 MTBS Extended 1445 47.710 -113.526 2001-08-03
Pre_ID Post_ID Perim_ID dNBR_offst dNBR_stdDv NoData_T
1 504102719840716 504102719860807 <NA> 20 -9999 -970
2 504102719880609 504102719920519 <NA> 10 -9999 -970
3 504002719890418 504002719940331 <NA> -25 34 -970
4 704102719991022 504102719991030 <NA> 26 -9999 -970
5 504102619990726 704102620000720 <NA> -15 -9999 -970
6 704002720000713 504002720020625 <NA> 69 -9999 -970
IncGreen_T Low_T Mod_T High_T Comment Shape_Leng Shape_Area
1 -150 130 250 800 <NA> 0.5669271 0.0025247432
2 -150 115 350 625 <NA> 0.2583140 0.0024534272
3 -150 0 250 9999 <NA> 0.5250718 0.0042204765
4 -150 130 420 9999 <NA> 0.1532660 0.0005656041
5 -150 85 334 615 <NA> 0.6459018 0.0056583482
6 -150 180 442 750 <NA> 0.1340689 0.0007008647
# make year a variable using str_sub()
fires <- fires %>% sf::st_as_sf() %>%
mutate(year = as.integer(stringr::str_sub(Ig_Date, 1, 4))) # take the first four digits from Ig_Date
# If this works, you will see map of fires that have occured in the Crown of the Continent since 1984. Older fires are green and more recent fires are red.
fires %>% ggplot() +
geom_sf(aes(fill = year), color = NA) + # fire perimeters
geom_sf(data = crown, fill = NA, color = "black", # crown boundary
size = 0.6) +
scale_fill_gradientn(colors = c("seagreen", "khaki", "darkred")) +
theme_minimal() +
labs(fill = "Year")
Now that we have “year” as a new variable, we can sum the area burned for all fires within year to create another new variable, “total area burned” (TAB).
[1] 1984 1985 1988 1991 1992 1993 1994 1996 1998 1999 2000 2001 2002 2003 2005
[16] 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
[31] 2021 2022 2023
I have downloaded drought PDSI data for western Montana from NOAA here. You can bring these data into R and clean it up a bit to make it usable for our purposes. Namely, we want to look at the relationship between total area burned and drought severity.
[1] "X...Montana"
[2] "Climate.Division.1.Palmer.Drought.Severity.Index..PDSI."
year_month pdsi
1 Date Value
2 198401 -0.46
3 198402 -1.11
4 198403 0.02
5 198404 0.45
6 198405 0.97
year_month pdsi year
1 198401 -0.46 1984
2 198402 -1.11 1984
3 198403 0.02 1984
4 198404 0.45 1984
5 198405 0.97 1984
6 198406 1.09 1984
year_month pdsi year month
1 198401 -0.46 1984 1
2 198402 -1.11 1984 2
3 198403 0.02 1984 3
4 198404 0.45 1984 4
5 198405 0.97 1984 5
6 198406 1.09 1984 6
[1] 1 2 3 4 5 6 7 8 9 10 11 12
Rows: 500
Columns: 4
$ year_month <chr> "198401", "198402", "198403", "198404", "198405", "198406",…
$ pdsi <chr> "-0.46", "-1.11", "0.02", "0.45", "0.97", "1.09", "0.77", "…
$ year <int> 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984,…
$ month <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7,…
Now, that we have monthly PDSI organized, let’s calculate annual average PDSI, plot PDSI across each year in our dataset, and join these data to our total area burned dataframe. To calculate average PDSI for each year, we first group_by year, then use summarise to create a new variable “mean_annual_PDSI” using mean().

# A tibble: 33 × 2
year TAB
* <int> <dbl>
1 1984 7990
2 1985 5221
3 1988 244213
4 1991 5123
5 1992 3088
6 1993 9793
7 1994 70778
8 1996 4461
9 1998 27539
10 1999 12626
# ℹ 23 more rows
# A tibble: 42 × 2
year mean_annual_PDSI
<int> <dbl>
1 1984 0.667
2 1985 -0.0542
3 1986 0.357
4 1987 -1.93
5 1988 -3.02
6 1989 0.462
7 1990 1.14
8 1991 -0.37
9 1992 -2.37
10 1993 0.464
# ℹ 32 more rows
Notice that there are NAs listed for total area burned. In our dataset, we may want to consider the total area burned as 0 in these cases. We will use mutate to turn NAs into 0 with a if_else. Keep in mind that the MTBS does not include fires <1,000 acres. If we report total area burned as 0, we should be aware that some small fires may have burned in those years.
After turning NAs into 0, plot TAB on the y-axis and mean_annual_PDSI on the x-axis. This explores the question “How is total area burned for each year related to the annual drought severity?”

What do you notice about the relationship?
Let’s see if seasonal drought severity might have a stronger relationship with total area burned. We need to calculate summer PDSI. We first will filter the data for June (month = 6), July (month = 7), and August (month = 8), group by year, and calculate mean PDSI. We will then join summer PDSI to the other dataframe to create a new dataframe called TAB_annual_summer_pdsi.
Now, plot total area burned against summer PDSI.

What do you make of this relationship?
One thing we might try is to fit quantile regression through the data. Quantile regression is an approach that allows you to fit linear models through different quantiles of the data. In other words, we can fit a model where the 90th (or other) quantile of response variable for different levels of the predictor variable. This can be useful when upper bounds of a relationship between a response and a predictor exists. See figure (below) and paper by Cade and Noon (2013) for an overview of the approach.
Figure inspired by Cade & Noon 2003, Frontiers in Ecology and the Environment 1(8):412–420. https://doi.org/10.1890/1540-9295(2003)001[0412:AGITQR]2.0.CO;2
Let’s try fitting quantile regression through the relationship between TAB and summer PDSI. We can easily do this in ggplot using geom_quantile where we set the quantiles we want to investigate (i.e., 0.1, 0.5, and 0.9 for the 10th quantile, median, and 90th quantile).

What do you make of this relationship? Let’s look at the relationship one more way.
We know that there are some really big fire years and some smaller fire years. This skewed distribution might warrant investigating the relationship between drought and total area burned after we log-transform TAB. Let’s try that. We can easily do that by “logging” TAB right in the ggplot. Let’s ignore the years with no fire using filter(TAB > 0). Let’s also include a linear model fit to the scatter plot using geom_smooth(method = "lm").
# This plot will show log-tranformed total area burned (TAB) on the y-axis and mean annual PDSI on the x-xis.A linear model with confidence intervals shows a general negative relationship.
TAB_annual_summer_pdsi %>% filter(TAB > 0) %>%
ggplot(aes(mean_summer_PDSI, log(TAB))) + geom_point() +
geom_smooth(method = "lm")
TASK 1.
Choose one approach to analyzing the relationship between total area burned and drought (annual or summer). Add nicer labels (hint: use ylab("Total area burned (acres)")) and customize at least one other part of the figure (change the theme, size, color, etc.) and write a thorough “stand alone” caption that describes the hypothesis, methods, results, and conclusion.
Next, we will investigate the statistical distribution of fire sizes. Fire sizes are often described as ‘highly skewed’ data that can either be characterized by a log-normal distribution or even a power-law distribution. Compared to a common distribution like the normal distribution, these skewed distributions are characterized by many observations of low values and few very large observations. For sizes of fires, this means that most fires are small and a few are really large. Let’s look to see if this pattern holds for fires in the Crown of the Continent.
We can use our fire data from above to easily explore these patterns. We will first plot a histogram of total area burned (BurnBndAc, which are burned area in acres).

Let’s log-transform acres burned to see if the data resemble a log-normal distribution (i.e., log-transforming log-normal data results in a normal distribution).

Do those data look normally distributed now?
Let’s plot acres burned for each fire after we rank them from largest to smallest. This is a rank size plot (if these were species, we would call this a rank-abundance plot). We make this using barplot of the data after sorting and telling R to sort in a decreasing way.

This is another way of investigating fire sizes similar to “Pareto plots”. I find the Pareto Principle, which colloquially has been called the 80/20 rule, fascinating. There are many phenomena where an important few (top 20% of instances) have a disproportionate (i.e., 80%) effect on an outcome. This has been applied to business (20% of customers generate 80% of revenues), our daily lives (we wear 20% of our clothes 80% of the time), to ecosystems (20% of the species contribute 80% of the biomass). Check out this video on Zipf’s law for a fun summary of some of these patterns.
These patterns have led fire scientists to study “power law distributions” with respect to fire sizes and how distributions of fire sizes reveal self-organized criticality. We don’t need to go there here, but let’s look to see if the “80/20 rule” for fire size distributions occurs in Montana. We have already sorted fires from largest to smallest. Next we’ll calculate the cumulative area burned starting with the largest fire, then the second largest fire, etc. Finally, we’ll calculate how each of these fires contribute to the total area burned. We’ll then create a Pareto plot and calculate some summary statistics.
We will do this one step at a time.
Incid_Name BurnBndAc
1 CHARLOTTE PEAK 5221
2 GAME RANGE 5123
3 FREEZEOUT LAKE 9793
4 MCDONALD 1174
5 ANACONDA 11452
6 BERGSICKER COMPLEX (CANNON) 1445
7 BERGSICKER COMPLEX (BERGSICKER) 5993
8 MOOSE 73210
9 BIGGS FLAT 7303
10 CABIN CREEK 1989
11 BIRK 8188
12 WEDGE CANYON 51987
13 LITTLE SALMON CREEK 33044
14 ROBERT 54500
15 LITTLE SALMON CREEK WILDLAND FIRE COMPLEX (MID) 10052
Incid_Name BurnBndAc
1 RICE RIDGE 171473
2 CANYON CREEK 167875
3 CHIPPY CREEK 95656
4 MOOSE 73210
5 BEAR CREEK 60710
6 ROBERT 54500
7 FOOL CREEK 53912
8 WEDGE CANYON 51987
9 FAMILY PEAK COMPLEX 49769
10 AHORN 45633
11 GATES PARK 42493
12 SKYLAND 41237
13 LINCOLN COMPLEX (SNOWBANK) 36987
14 JOCKO LAKES 35759
15 RED BENCH 33845
What is the name of the largest fire?
Incid_Name BurnBndAc rank
1 RICE RIDGE 171473 1
2 CANYON CREEK 167875 2
3 CHIPPY CREEK 95656 3
4 MOOSE 73210 4
5 BEAR CREEK 60710 5
6 ROBERT 54500 6
7 FOOL CREEK 53912 7
8 WEDGE CANYON 51987 8
9 FAMILY PEAK COMPLEX 49769 9
10 AHORN 45633 10
11 GATES PARK 42493 11
12 SKYLAND 41237 12
13 LINCOLN COMPLEX (SNOWBANK) 36987 13
14 JOCKO LAKES 35759 14
15 RED BENCH 33845 15
Incid_Name BurnBndAc rank cum_area
1 RICE RIDGE 171473 1 171473
2 CANYON CREEK 167875 2 339348
3 CHIPPY CREEK 95656 3 435004
4 MOOSE 73210 4 508214
5 BEAR CREEK 60710 5 568924
6 ROBERT 54500 6 623424
7 FOOL CREEK 53912 7 677336
8 WEDGE CANYON 51987 8 729323
9 FAMILY PEAK COMPLEX 49769 9 779092
10 AHORN 45633 10 824725
11 GATES PARK 42493 11 867218
12 SKYLAND 41237 12 908455
13 LINCOLN COMPLEX (SNOWBANK) 36987 13 945442
14 JOCKO LAKES 35759 14 981201
15 RED BENCH 33845 15 1015046
Incid_Name BurnBndAc rank cum_area cum_percent
1 RICE RIDGE 171473 1 171473 7.584938
2 CANYON CREEK 167875 2 339348 15.010722
3 CHIPPY CREEK 95656 3 435004 19.241971
4 MOOSE 73210 4 508214 22.480342
5 BEAR CREEK 60710 5 568924 25.165789
6 ROBERT 54500 6 623424 27.576543
7 FOOL CREEK 53912 7 677336 29.961286
8 WEDGE CANYON 51987 8 729323 32.260880
9 FAMILY PEAK COMPLEX 49769 9 779092 34.462362
10 AHORN 45633 10 824725 36.480893
11 GATES PARK 42493 11 867218 38.360528
12 SKYLAND 41237 12 908455 40.184606
13 LINCOLN COMPLEX (SNOWBANK) 36987 13 945442 41.820689
14 JOCKO LAKES 35759 14 981201 43.402453
15 RED BENCH 33845 15 1015046 44.899553
# Add the percent of total NUMBER of fires as a cumulative total
fires %>%
st_drop_geometry() %>%
dplyr::select(Incid_Name, BurnBndAc) %>%
arrange(desc(BurnBndAc)) %>%
mutate(rank = row_number()) %>%
mutate(
cum_area = cumsum(BurnBndAc),
cum_percent = cum_area / sum(BurnBndAc) * 100,
cum_fire_pct = rank / n() * 100) %>%
head(30) Incid_Name BurnBndAc rank cum_area cum_percent
1 RICE RIDGE 171473 1 171473 7.584938
2 CANYON CREEK 167875 2 339348 15.010722
3 CHIPPY CREEK 95656 3 435004 19.241971
4 MOOSE 73210 4 508214 22.480342
5 BEAR CREEK 60710 5 568924 25.165789
6 ROBERT 54500 6 623424 27.576543
7 FOOL CREEK 53912 7 677336 29.961286
8 WEDGE CANYON 51987 8 729323 32.260880
9 FAMILY PEAK COMPLEX 49769 9 779092 34.462362
10 AHORN 45633 10 824725 36.480893
11 GATES PARK 42493 11 867218 38.360528
12 SKYLAND 41237 12 908455 40.184606
13 LINCOLN COMPLEX (SNOWBANK) 36987 13 945442 41.820689
14 JOCKO LAKES 35759 14 981201 43.402453
15 RED BENCH 33845 15 1015046 44.899553
16 LITTLE SALMON CREEK 33044 16 1048090 46.361222
17 RED EAGLE 32563 17 1080653 47.801614
18 BRUSH CREEK 30166 18 1110819 49.135977
19 ALICE CREEK 29971 19 1140790 50.461715
20 ELBOW PASS COMPLEX 28989 20 1169779 51.744014
21 LIBERTY 27731 21 1197510 52.970668
22 BARTLETT MOUNTAIN 27614 22 1225124 54.192145
23 RAMPAGE COMPLEX (DOUBLE MOUNTAIN 2) 23680 23 1248804 55.239607
24 CONGER CREEK 22936 24 1271740 56.254158
25 MONTURE-SPREAD RIDGE (MONTURE) 22493 25 1294233 57.249114
26 TRAIL CREEK 22338 26 1316571 58.237213
27 ELMO 22148 27 1338719 59.216908
28 MINERAL-PRIMM (MINERAL AND PRIMM) 20888 28 1359607 60.140868
29 NIARADA 20686 29 1380293 61.055892
30 SCALP 20309 30 1400602 61.954241
cum_fire_pct
1 0.5291005
2 1.0582011
3 1.5873016
4 2.1164021
5 2.6455026
6 3.1746032
7 3.7037037
8 4.2328042
9 4.7619048
10 5.2910053
11 5.8201058
12 6.3492063
13 6.8783069
14 7.4074074
15 7.9365079
16 8.4656085
17 8.9947090
18 9.5238095
19 10.0529101
20 10.5820106
21 11.1111111
22 11.6402116
23 12.1693122
24 12.6984127
25 13.2275132
26 13.7566138
27 14.2857143
28 14.8148148
29 15.3439153
30 15.8730159
# plot this as a Pareto chart
# This will show burned area on the y-axis for fires rank largest to smallest with a cumulative area curve that rises quickly and levels off.
fires %>%
st_drop_geometry() %>%
dplyr::select(Incid_Name, BurnBndAc) %>%
arrange(desc(BurnBndAc)) %>%
mutate(rank = row_number()) %>%
mutate(
cum_area = cumsum(BurnBndAc),
cum_percent = cum_area / sum(BurnBndAc) * 100,
cum_fire_pct = rank / n() * 100) %>%
ggplot(aes(x = rank)) +
geom_col(aes(y = BurnBndAc), fill = "grey") +
geom_line(aes(y = cum_percent * max(BurnBndAc) / 100),
color = "steelblue", size = 1) +
scale_y_continuous(
name = "Burned Area (acres)",
sec.axis = sec_axis(~ . / max(fires$BurnBndAc) * 100,
name = "Cumulative %")) +
labs(x = "Fire Rank (largest to smallest)", y = "Burned Area (acres)") +
theme_minimal()
TASK 2.
Look at the plot and use View() to look at the data to see what percentage of fires burned what percentage of total area burned. Do fires in the Crown of the Continent follow the 80/20 rule? Consider these patterns in light of a quote I once heard from a fire manager: “there are fires we put out, and there are fires we get out of the way of.” Consider the causes and consequences of these patterns for ecosystems and people, interpret the results, and write an abstract in the format of Landscape Ecology.
We know that many complex and interacting factors govern the spatial patterns and severity of disturbances, especially fires. In the next exercise, we will explore how topography (heat load index and elevation) and vegetation (greenness of vegetation before a fire) affects the severity of a fire and whether these patterns vary depending on the climate and fire conditions for the year. We will be looking at two estimate of fire severity: the classification of the Monitoring Trends in Burn Severity (MTBS) and the continuous composite burn index of Parks et al. (2025).
First, let’s consider the landscape patterns among fires that burned between 1985 and 2022. Plot fires that we brought in earlier, pan around the Crown of the Continent and consider where fires occur, when, and how they interact with each other and the landscape.
# This will open an interactive plot of fires in the Crown of the Continent.
# mapview::mapview(fires, zcol = "year", col.regions = c("seagreen", "khaki", "darkred"))
if (knitr::is_html_output()) {
mapview::mapview(fires, zcol = "year", col.regions = c("seagreen", "khaki", "darkred"))
} else {
ggplot(fires) +
geom_sf(aes(fill = year)) +
scale_fill_gradientn(colors = c("seagreen", "khaki", "darkred")) +
theme_bw() +
labs(fill = "Year")
}