This document is used to produce some tables from the Uganda
livestock test model output. The tables can be compared with other model
revisions.
Human Sanitation Attribution
Print the attribution of sanitation types to the surface water
emissions.
fpath <- testthat::test_path("output/uga_livestock/human_sources_water_crypto_uga.csv")
df_human_attribution <- read.csv(fpath)
n_digits <- 5
df_print <- df_human_attribution %>%
dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE) %>%
dplyr::rename_with(~ stringr::str_trunc(.x, 10))
df_print %>% dplyr::select(iso, 2:8)
| 800 |
2.3622e+13 |
5.4187e+12 |
0 |
1.4735e+13 |
4.3119e+13 |
6.9398e+13 |
1.5009e+14 |
df_print %>% dplyr::select(iso, 9:14)
| 800 |
4.4205e+13 |
4.7244e+13 |
2.0018e+15 |
2.3622e+14 |
5.4371e+15 |
1.0926e+15 |
Livestock Attribution
Print the attribution of livestock types to the surface water
emissions.
fpath <- testthat::test_path("output/uga_livestock/livestock_sources_water_crypto_uga.csv")
df_livestock_attribution <- read.csv(fpath)
df_print <- df_livestock_attribution %>%
dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE)
df_print %>% dplyr::select(iso, 2:6)
| 800 |
1.2082e+15 |
0 |
7.5169e+14 |
2.9005e+19 |
5.4526e+18 |
df_print %>% dplyr::select(iso, 7:11)
| 800 |
3.1775e+11 |
0 |
1.0654e+18 |
2.3874e+18 |
2.6995e+17 |
Surface Water Pathways
Print the attribution from various pathways to the surface water
emissions.
fpath <- testthat::test_path("output","uga_livestock","surface_water_emissions_crypto_uga.csv")
df_pathways_water <- read.csv(fpath)
df_pathways_water %>%
dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE)
| 800 |
9.0791e+15 |
3.8182e+19 |
6.8132e+13 |
Land Pathways
Print the attribution from various pathways to land emissions.
fpath <- testthat::test_path("output","uga_livestock","land_emissions_crypto_uga.csv")
df_pathways_land <- read.csv(fpath)
df_pathways_land %>%
dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE)
| 800 |
7.2905e+14 |
1.364e+21 |
1.6328e+20 |
Maps
fpath <- testthat::test_path("output","uga_livestock","pathways.tif")
rast_pathways <- terra::rast(fpath)
terra::plot(log10(rast_pathways), col = hcl.colors(50, palette = "Geyser"), buffer = TRUE)

Compare Gridded vs Tabular
rast_zones <-
terra::rast(system.file("extdata/uga_livestock/isoraster_uga.tif", package =
"glowpa"))
zonal_sums <- terra::zonal(rast_pathways, rast_zones, fun = "sum", na.rm = TRUE)
zonal_sums %>% dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE) %>%
dplyr::select(dplyr::contains(c("livestock","manure")))
| 8.4036e+20 |
NaN |
1.364e+21 |
1.6328e+20 |
fpath <-
testthat::test_path("output/uga_livestock/land_emissions_crypto_uga.csv")
df_land <- read.csv(fpath)
df_land %>%
dplyr::mutate_if(is.numeric, format, digits = n_digits, scientific = TRUE)
| 800 |
7.2905e+14 |
1.364e+21 |
1.6328e+20 |