# For general data science
library(tidyverse)

# For reading Excel files
library(readxl)

# For data cleaning
library(janitor)

# For working with datetime
library(lubridate)

# For pretty tables
library(knitr)
library(gt)

knitr::opts_chunk$set(echo = TRUE)

Introduction

Oil and gas companies in Wyoming use an online portal to report the volumes of gas flared, vented and used on the lease, along with the number of days that flaring and venting occurred. While there is no publicly available form, the Wyoming Oil and Gas Conservation Commission confirmed that the data made public on its website is what is submitted. For reference, here is the WOGCC packet companies follow when they start filing electronically.

Data from the monthly reports (2014-present) are available at the WOGCC’s data website, which has statewide and county-specific data sets for each year. Click “Production” and then “Flaring, Vented, Lease Use Data by Selected County and Yr.” From the drop down menu, select “Wyoming” for data from all counties, and then select a given year. Click “submit” to download the file in .xls format. Each row represents a company’s annual record for flaring and venting from a particular well drilling from a particular formation.

Load data

We compiled and cleaned the data from the state regulatory agency and saved it as a new dataset available from the Howard Center here. (For more information about our data cleaning, please contact: )

wy <- read.csv(url("https://cronkitedata.s3.amazonaws.com/howard/gaslit/wy_flaring_and_venting.csv"))

Analysis

FACT: From 2014 to 2020, oil and gas companies reported flaring 35,937,487,000 cubic feet – and venting 1,560,682,000 – cubic feet of gas.

We grouped by year to calculate annual totals, adding an additional column, “combined,” that takes the sum of both vented and flared volumes.

wy_annualtotals <- wy  %>%
  group_by(yr) %>%
  summarise(Flared = sum(flared, na.rm = TRUE),
            Vented = sum(vented, na.rm = TRUE)) %>%
  mutate(Combined = rowSums(across(c(Flared:Vented))))
  
# Pretty table
wy_annualtotals %>%
  gt(rowname_col = "yr") %>%
  tab_stubhead(label = "Year") %>%
  tab_header(title = "Flaring and Venting Volumes Reported to WOGCC",
             subtitle = "Flaring and venting volumes in Mcf (thousand cubic feet)") %>%
  fmt_number(column = "Flared":"Combined",
             decimals = 0) %>%
  grand_summary_rows(fns = list("Total" = "sum"), 
                           columns=("Flared":"Combined"), 
                           formatter=gt::fmt_number, 
                           decimals=0)
Flaring and Venting Volumes Reported to WOGCC
Flaring and venting volumes in Mcf (thousand cubic feet)
Year Flared Vented Combined
2014 6,138,249 26,293 6,164,542
2015 5,483,468 9,661 5,493,129
2016 2,463,680 184,527 2,648,207
2017 3,445,721 311,395 3,757,116
2018 5,909,743 411,303 6,321,046
2019 8,137,620 440,822 8,578,442
2020 4,359,006 176,681 4,535,687
Total 35,937,487 1,560,682 37,498,169
LS0tCnRpdGxlOiAiV3lvbWluZyAgRmxhcmluZyBhbmQgVmVudGluZyIKYXV0aG9yOiAiSmltbXkgQ2xvdXRpZXIsIE1pY2hhZWwgTWNEYW5pZWwiCm91dHB1dDoKICAgIGh0bWxfZG9jdW1lbnQ6CiAgICAgIGNvZGVfZm9sZGluZzogc2hvdwogICAgICBkZl9wcmludDogcGFnZWQKICAgICAgdG9jOiB0cnVlCiAgICAgIHRvY19mbG9hdDogdHJ1ZQogICAgICBjb2RlX2Rvd25sb2FkOiB0cnVlCi0tLQoKYGBge3Igc2V0dXAsIG1lc3NhZ2U9RkFMU0UsIGNsYXNzLnNvdXJjZT0iZm9sZC1oaWRlIn0KCiMgRm9yIGdlbmVyYWwgZGF0YSBzY2llbmNlCmxpYnJhcnkodGlkeXZlcnNlKQoKIyBGb3IgcmVhZGluZyBFeGNlbCBmaWxlcwpsaWJyYXJ5KHJlYWR4bCkKCiMgRm9yIGRhdGEgY2xlYW5pbmcKbGlicmFyeShqYW5pdG9yKQoKIyBGb3Igd29ya2luZyB3aXRoIGRhdGV0aW1lCmxpYnJhcnkobHVicmlkYXRlKQoKIyBGb3IgcHJldHR5IHRhYmxlcwpsaWJyYXJ5KGtuaXRyKQpsaWJyYXJ5KGd0KQoKa25pdHI6Om9wdHNfY2h1bmskc2V0KGVjaG8gPSBUUlVFKQoKYGBgCgojIEludHJvZHVjdGlvbiAKCk9pbCBhbmQgZ2FzIGNvbXBhbmllcyBpbiBXeW9taW5nIHVzZSBhbiBvbmxpbmUgcG9ydGFsIHRvIHJlcG9ydCB0aGUgdm9sdW1lcyBvZiBnYXMgZmxhcmVkLCB2ZW50ZWQgYW5kI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