Skip to content

Commit

Permalink
Merge pull request #42 from Metropolitan-Council/10-solid-waste-data-…
Browse files Browse the repository at this point in the history
…sourcing

Solid waste data sourcing
  • Loading branch information
eroten authored Feb 3, 2024
2 parents 62f1d2f + 3df6b30 commit c966760
Show file tree
Hide file tree
Showing 96 changed files with 17,073 additions and 370 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ _energy/data-raw/*/
.DS_Store

_transportation/report_transportation_files/figure-html/
_waste/data-raw/score_summary.csv
_waste/data-raw/ghg-emission-factors-hub-2021.xlsx

R/WI_Cities%2C_Towns_and_Villages_(July_2023)/

Expand Down Expand Up @@ -141,3 +143,33 @@ _energy/data-raw/eGRID2021_data.xlsx
_energy/data-raw/eGRID2021_summary_tables.xlsx

_energy/data-raw/egrid2022_summary_tables.xlsx

_waste/pa_waste.html

_waste/qc_waste_other.html

_waste/qc_waste.html

_waste/_waste.html

tables.html

figures.html

references.html

_meta/data_request_template.html

_meta/supplementary_data.html

_meta/supplementary_tables.html

_transportation/_transportation.html

_transportation/data_transportation.html

_transportation/pa_transportation.html

_transportation/qc_transportation.html

caption_index.RDS
2 changes: 1 addition & 1 deletion R/remove_caches.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ list.files(path = "_waste/", pattern = "*.html", full.names = TRUE) %>%
fs::file_delete()

list.files(path = "_meta/", pattern = "*.html", full.names = TRUE) %>%
fs::dir_delete()
fs::file_delete()

# delete all captions
list.files("assets/captions/", full.names = TRUE) %>%
Expand Down
5 changes: 3 additions & 2 deletions R/render_for_publication.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
source("R/_load_pkgs.R")
source("R/remove_caches.R")
source("_meta/data-raw/compile_county_emissions.R")
# if necessary, remove all cache's and stray html files
# source("R/remove_caches.R")
saveRDS("00", file.path(here::here(), "caption_index.RDS"))

styler::style_dir()

testthat::test_dir("tests")
Expand Down
5 changes: 4 additions & 1 deletion _energy/_energy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ plot_county_emissions(


```{r echo=FALSE}
saveCap("energy")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _energy/_energy_electricity_emissions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,8 @@ plot_ly(
- 2018 Met Council inventory

```{r echo=FALSE}
saveCap("electricity-emissions")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
7 changes: 5 additions & 2 deletions _energy/_energy_natural_gas_emissions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ plot_ly(
We would expect counties with higher population to have higher emissions.

```{r fig-ng-emissions-population}
#| fig-cap: "County population and emissions"
#| fig-cap: "County population and natural gas emissions"
#| out-width: "95%"
cprg_population <- readRDS(file.path(here::here(), "_meta/data/cprg_population.RDS"))
emissions_population <- left_join(natGasEmissions_all, cprg_population,
Expand Down Expand Up @@ -158,5 +158,8 @@ plot_ly(
- 2018 Met Council inventory

```{r echo=FALSE}
saveCap("natural-gas-emissions")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _energy/data_electricity.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@ Be sure to add a citation of this dataset to the Zotero shared library.
### Data dictionaries

```{r echo=FALSE}
saveCap("energy-data-electricity")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _energy/data_energy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ source(file.path(here::here(), "R/_load_pkgs.R"))
hookaddcap()
```


```{r echo=FALSE}
saveCap("energy-data")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _energy/data_natural_gas.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ Be sure to add a citation of this dataset to the Zotero shared library.
### Data dictionaries

```{r echo=FALSE}
saveCap("energy-data")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _energy/data_propane_kerosene.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ Table with detailed description of columns and definitions for each data table.


```{r echo=FALSE}
saveCap("propane-kerosene-sourcing")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _energy/pa_energy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ hookaddcap()
<!-- chapter content -->



```{r echo=FALSE}
saveCap("pa-energy")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _energy/qc_energy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ tibble::tribble(
gt::as_raw_html()
```


```{r echo=FALSE}
saveCap("qc-energy")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _energy/utility_service_area_maps.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ WI_ng_inScope_servTerrs <- council_leaflet() %>%
WI_ng_inScope_servTerrs
```


```{r echo=FALSE}
saveCap("utility-service-maps")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _meta/additional_resources.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ hookaddcap()

- U.S. Energy Information Administration (EIA) Glossary, available on their [website](https://www.eia.gov/tools/glossary/).


```{r echo=FALSE}
saveCap("additional-resources")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
21 changes: 20 additions & 1 deletion _meta/data-raw/compile_county_emissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ ww_emissions <- readRDS("_energy/data/wastewater.RDS") %>%


## solid waste -----
solid_waste <- readRDS("_waste/data/county_sw_emissions.RDS") %>%
ungroup() %>%
mutate(
sector = "Waste",
geog_level = "county",
geog_name = county,
category = "Solid Waste",
source = source,
data_source,
factor_source = "EPA GHG Emission Factors Hub (2021)"
) %>%
select(names(transportation_emissions))



# energy -----
## electricity ----
electric_raw <- readRDS(file.path(here::here(), "_energy/data/minnesota_county_ElecEmissions.RDS")) %>%
Expand Down Expand Up @@ -105,7 +120,8 @@ emissions_all <- bind_rows(
propane_kerosene_emissions,
electric_emissions,
natural_gas_emissions,
ww_emissions
ww_emissions,
solid_waste
) %>%
left_join(
cprg_county %>%
Expand All @@ -120,6 +136,9 @@ emissions_all <- bind_rows(
"Medium-duty vehicles",
"Heavy-duty vehicles",
# waste levels
"Landfill",
"Recycling",
"Organics",
"Wastewater",
# energy levels
"Electricity",
Expand Down
29 changes: 29 additions & 0 deletions _meta/data/cprg_county_emissions.CSV
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,32 @@
2020,"county","053","Hennepin","Waste","Wastewater","Wastewater",84021.7041006264,"Wastewater","Wastewater"
2020,"county","123","Ramsey","Waste","Wastewater","Wastewater",36213.1895794511,"Wastewater","Wastewater"
2020,"county","141","Sherburne","Waste","Wastewater","Wastewater",6371.4920972492,"Wastewater","Wastewater"
2021,"county","003","Anoka","Waste","Solid Waste","Landfill",105380.3326,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","019","Carver","Waste","Solid Waste","Landfill",29200.5112,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","025","Chisago","Waste","Solid Waste","Landfill",20457.7412,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","037","Dakota","Waste","Solid Waste","Landfill",122239.8536,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","053","Hennepin","Waste","Solid Waste","Landfill",382775.54,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","123","Ramsey","Waste","Solid Waste","Landfill",143967.037,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","139","Scott","Waste","Solid Waste","Landfill",40439.6237,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","141","Sherburne","Waste","Solid Waste","Landfill",21909.34764,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","163","Washington","Waste","Solid Waste","Landfill",53248.0403,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","003","Anoka","Waste","Solid Waste","Organics",7561.6646,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","019","Carver","Waste","Solid Waste","Organics",4809.3374,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","025","Chisago","Waste","Solid Waste","Organics",1224.4369,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","037","Dakota","Waste","Solid Waste","Organics",23737.4043,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","053","Hennepin","Waste","Solid Waste","Organics",27869.9224,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","123","Ramsey","Waste","Solid Waste","Organics",18024.8127,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","139","Scott","Waste","Solid Waste","Organics",5100.1071,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","141","Sherburne","Waste","Solid Waste","Organics",1133.0398,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","163","Washington","Waste","Solid Waste","Organics",6045.0725,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","003","Anoka","Waste","Solid Waste","Recycling",17823.2724,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","019","Carver","Waste","Solid Waste","Recycling",3919.4181,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","025","Chisago","Waste","Solid Waste","Recycling",756.6354,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","037","Dakota","Waste","Solid Waste","Recycling",12578.5404,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","053","Hennepin","Waste","Solid Waste","Recycling",30815.2845,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","123","Ramsey","Waste","Solid Waste","Recycling",7134.6672,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","139","Scott","Waste","Solid Waste","Recycling",5246.8938,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","141","Sherburne","Waste","Solid Waste","Recycling",3057.6681,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","163","Washington","Waste","Solid Waste","Recycling",7529.0319,"MPCA SCORE","EPA GHG Emission Factors Hub (2021)"
2021,"county","093","Pierce","Waste","Solid Waste","Landfill",15756.844830377,"Wisconsin DNR","EPA GHG Emission Factors Hub (2021)"
2021,"county","109","St. Croix","Waste","Solid Waste","Landfill",34915.0061132888,"Wisconsin DNR","EPA GHG Emission Factors Hub (2021)"
Binary file modified _meta/data/cprg_county_emissions.RDS
Binary file not shown.
5 changes: 4 additions & 1 deletion _meta/supplementary_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,8 @@ cprg_ctu_meta %>%


```{r echo=FALSE}
saveCap("supp-data")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _meta/supplementary_tables.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ tibble::tribble(
gt::as_raw_html()
```
```{r echo=FALSE}
saveCap("supp-tables")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
10 changes: 6 additions & 4 deletions _transportation/_transportation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ plot_ly(

We would expect counties with higher population to have higher emissions and VMT.

```{r fig-emissions-population}
#| fig-cap: "County population and emissions"
```{r fig-emissions-population-transportation}
#| fig-cap: "County population and transportation emissions"
#| out-width: "95%"
cprg_population <- readRDS(file.path(here::here(), "_meta/data/cprg_population.RDS"))
vmt_population <- left_join(vmt_emissions_all, cprg_population,
Expand Down Expand Up @@ -295,7 +295,9 @@ lggit_total_emiss <- (lggit_totals$total %>% sum()) %>% scales::comma()
```

The results from the LGGIT tool indicate a regional total of **`r lggit_total_emiss` metric tons CO~2~e**, while our calculations indicate **`r cprg_total_emiss` metric tons CO~2~e**. These values are sufficiently close, and may be explained by differences between nationwide vehicle emission rates and fuel efficiency and region-specific values from EPA MOVES. See @sec-epa-moves for a more detailed comparison.

```{r echo=FALSE}
saveCap("trans")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
2 changes: 1 addition & 1 deletion _transportation/data-raw/epa_ghg_state.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# get data from state GHG emissions and removals
# https://www.epa.gov/ghgemissions/state-ghg-emissions-and-removals
source("R/_load_pkgs.R")
cprg_county <- readRDS("R/data/cprg_county.RDS")
cprg_county <- readRDS("_meta/data/cprg_county.RDS")


# ipcc sectors -----
Expand Down
6 changes: 4 additions & 2 deletions _transportation/data_epa_moves.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ epa_moves_meta %>%

Table with detailed description of columns and definitions for each data table.


```{r echo=FALSE}
saveCap("epa-moves")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _transportation/data_state_dot.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,8 @@ Table with detailed description of columns and definitions for each data table.


```{r echo=FALSE}
saveCap("state-dot")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _transportation/data_streetlight.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -501,5 +501,8 @@ To maximize data availability, we used the most recent data available, up to 202
Table with detailed description of columns and definitions for each data table.

```{r echo=FALSE}
saveCap("stl-data")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
6 changes: 4 additions & 2 deletions _transportation/data_tbi.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ Be sure to add a citation of this dataset to the Zotero shared library.

Table with detailed description of columns and definitions for each data table.


```{r echo=FALSE}
saveCap("data-tbi")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _transportation/data_transportation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ hookaddcap()


```{r echo=FALSE}
saveCap("trans-data")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _transportation/pa_transportation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ hookaddcap()


```{r echo=FALSE}
saveCap("pa-transportation")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
5 changes: 4 additions & 1 deletion _transportation/qc_transportation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ tibble::tribble(
```

```{r echo=FALSE}
saveCap("qc-transportation")
caption_index <- readRDS(file.path(here::here(), "caption_index.RDS"))
caption_index <- as.character(as.numeric(caption_index) + 1) %>% stringr::str_pad(width = 2, side = "left", pad = "0")
saveCap(paste0("cap-", caption_index))
saveRDS(caption_index, file.path(here::here(), "caption_index.RDS"))
```
Loading

0 comments on commit c966760

Please sign in to comment.