# For general data science
library(tidyverse)

# For reading and writing data tables and Excel files
library(data.table)
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

In Alaska, oil and gas companies are required to submit monthly reports detailing the volumes of gas flared or vented at each facility to the Alaska Oil and Gas Conservation Commission (AOGCC). They use Form 10-422, the Facility Report of Produced Gas Disposition, which includes fields for the volumes of gas produced, sold, reinjected, flared or vented for one hour or less, flared or vented for more than one hour, and handled via other disposition options. A copy of Form 10-422 and its instructions are available from the AOGCC website. There are two lines, 8 and 9, for producers to report flaring and venting. Volumes must be reported in thousand cubic feet (MCF) at 14.65 PSIA at 60° Fahrenheit.

Data from the monthly reports (1995- present) is available at the AOGCC’s data website in a data set called “Data Extract,” which is updated monthly.

Load Data

Data from the AOGCC site is available in Microsoft Access (.mdb) format. We extracted the relevant data table containing flaring and venting volumes from the file using MDB Tools and saved it to a new data set available from the Howard Center here. (For more information about our data cleaning, please contact: ).

ak <- read.csv( url("https://cronkitedata.s3.amazonaws.com/howard/gaslit/ak_flaring_and_venting.csv")) %>%
  clean_names() %>%
  # convert `rpt_date` to datetime & extract year
  mutate(rpt_date = as.Date(rpt_date, format = "%m/%d/%y"),
         dt_mod = as.Date(dt_mod, format = "%m/%d/%y"),
         yr = year(rpt_date)) %>%
  # select and reorder columns we want 
  select(disp_key, yr, rpt_date, facility_no, field_pool, opno, flare_gtr, flare_lt, dt_mod)

Analysis

FACT: “Between 2012 and 2020, oil and gas operators in Alaska reported flaring and venting more than 27 billion cubic feet of gas.”

This volume was calculated by aggregating the totals reported by companies. We created a new Total column to add up the volumes from two separate columns, one for flaring and venting events that lasted less than on hour, and one for flaring and venting events that lasted for one hour or longer. We also extracted the year from the report date and created a new yr column, then filtered for the years 2012 to 2020, the time frame we were looking at for this investigation. Finally, we grouped by year to calculate the annual totals.

ak_annualtotals <- ak %>%
  filter(yr >= 2012 & yr <= 2020) %>%
  mutate(flared = rowSums (across("flare_lt":"flare_gtr"))) %>%
  group_by(yr) %>%
  summarise(Total = sum(flared, na.rm = TRUE ))


# Pretty table
ak_annualtotals %>%
  gt(rowname_col = "yr") %>%
  tab_stubhead( label = "Year" ) %>%
  tab_header( title = "Flaring and Venting Volumes Reported to AOGCC",
             subtitle = "Flaring and venting volumes in MCF (thousand cubic feet)") %>%
  fmt_number(column = "Total",
             decimals = 0) %>%
  grand_summary_rows(fns = list("Total" = "sum"), 
                           columns=("Total"), 
                           formatter=gt::fmt_number, 
                           decimals=0)
Flaring and Venting Volumes Reported to AOGCC
Flaring and venting volumes in MCF (thousand cubic feet)
Year Total
2012 3,987,801
2013 3,206,780
2014 2,625,477
2015 1,406,259
2016 4,393,122
2017 2,864,270
2018 4,238,684
2019 3,027,357
2020 1,495,707
Total 27,245,457
LS0tCnRpdGxlOiAiQWxhc2thIEZsYXJpbmcgJiBWZW50aW5nIgphdXRob3I6ICJMYXVyYSBLcmFlZ2VsLCBTYXJhaCBTdXdhbHNreSIKb3V0cHV0OgogICAgaHRtbF9kb2N1bWVudDoKICAgICAgY29kZV9mb2xkaW5nOiBzaG93CiAgICAgIGRmX3ByaW50OiBwYWdlZAogICAgICB0b2M6IHRydWUKICAgICAgdG9jX2Zsb2F0OiB0cnVlCiAgICAgIGNvZGVfZG93bmxvYWQ6IHRydWUKICAgIAotLS0KCmBgYHtyIHNldHVwLCBtZXNzYWdlPUZBTFNFLCBjbGFzcy5zb3VyY2U9ImZvbGQtaGlkZSJ9CgojIEZvciBnZW5lcmFsIGRhdGEgc2NpZW5jZQpsaWJyYXJ5KHRpZHl2ZXJzZSkKCiMgRm9yIHJlYWRpbmcgYW5kIHdyaXRpbmcgZGF0YSB0YWJsZXMgYW5kIEV4Y2VsIGZpbGVzCmxpYnJhcnkoZGF0YS50YWJsZSkKbGlicmFyeShyZWFkeGwpCgojIEZvciBkYXRhIGNsZWFuaW5nCmxpYnJhcnkoamFuaXRvcikKCiMgRm9yIHdvcmtpbmc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