
Build the livestock greenhouse-gas emissions extension.
Source:R/livestock_ghg_extension.R
build_livestock_ghg_extension.RdAggregate per-animal IPCC livestock emissions into a footprint extension
keyed by (year, area_code, item_cbs_code), expressed in kilograms of
carbon-dioxide equivalent (CO2e). This bridges the cohort-level emissions
pipeline (calculate_livestock_emissions()) to the input-output grain used
by build_io_model() and compute_footprint(), exactly like
build_grassland_land_extension() does for land.
Live-animal head counts come from get_primary_production(), are bridged to
IPCC species with prepare_livestock_emissions(), and the resulting enteric
and manure emissions are converted to CO2e and summed back to the
live-animal commodity sector (item_cbs_code, e.g. 961 for non-dairy
cattle), which is itself a sector in build_io_model().
Two IPCC tiers are available, selected with tier:
1(default): Tier 1 regional emission factors (IPCC 2019). It needs only species, country and head counts, so it is complete for every country inget_primary_production(). It covers enteric and manure methane and manure N2O (direct and indirect, from default per-head nitrogen excretion rates).2: Tier 2 cohort energy balance (IPCC 2019). It derives enteric CH4 and manure N2O from a per-animal energy and nitrogen balance, for finer resolution, but requires cohort weight and diet inputs. Animals whose emissions cannot be resolved (missing diet or energy data) are dropped with a warning rather than entering the footprint asNA. Its per-head enteric and manure emissions now sit in the same range as the Tier 1 regional factors. Tier 1 remains the default because it is complete for every country inget_primary_production(), whereas Tier 2 needs cohort and diet inputs.
The CO2e conversion uses 100-year global warming potentials selected with
gwp:
"ar6"(default): IPCC AR6 (2021) Table 7.15, biogenic CH4 = 27, N2O = 273."ar5": IPCC AR5 (2013), CH4 = 28, N2O = 265 (no climate-carbon feedback)."ar4": IPCC AR4 (2007), CH4 = 25, N2O = 298.
Arguments
- tier
IPCC tier,
1(default) or2.- gwp
100-year global warming potential standard,
"ar6"(default),"ar5"or"ar4".- data
Optional named list of pre-loaded inputs to avoid remote reads:
primary_prod(theget_primary_production()output). It falls back to its reader when absent.- example
If
TRUE, return a small fixture instead of reading remote data. Defaults toFALSE.
Value
A tibble with columns year, area_code, item_cbs_code,
impact_u (livestock emissions in kilograms CO2e) and method_ghg (the
chosen tier and GWP standard, e.g. "IPCC_2019_Tier1_AR6"), plus the
polity columns below.
Polity columns
Every area-keyed output carries the polity its area_code resolves to in
that row's year:
polity_area_code: The numeric key rows are AGGREGATED on, for the matrix workflows. It is a bucket, not an identity: usereporting_polity_codeto say which territory a row belongs to.reporting_polity_code: The polity itself, e.g.ESP-1846-1914. It is year-aware, so the samearea_coderesolves to different polities in different years, which is the point of the crosswalk.reporting_polity_name: Its name. It can differ from the area's own name where the area folds into an aggregate.reporting_polity_has_geometry: Whether the polity has a polygon in the WHEP polity database, for callers that need to map or intersect it.FALSEis a documented gap upstream, not an error.
Rows whose area_code resolves to no polity keep the columns with NA
rather than being dropped, so a gap is visible instead of silent.
Rows before the back-cast anchor year resolve to the polity live in that
anchor year rather than to the polity live in the row's own year, because
WHEP's pre-anchor series are back-cast onto the anchor-year territory. See
add_polity_code() for the reasoning. Where that polity is not live in the
row's own year – 41.5% of the pre-1961 (area, year) cells –
add_polity_code() says so as mapping_status == "backcast_anchor", and
polity_coverage_gaps() reports it as gap_kind == "backcast_anchor".
These columns do not say so either way.
A row whose year no mapped period covers is resolved to the NEAREST period of
the same area instead, so reporting_polity_code can name a polity that did
not exist in that row's year – FAOSTAT bucket 206 "Sudan (former)" keeps
reporting after SUD-1956-2011 ends, and its post-2011 rows carry that code.
These columns do not say so: add_polity_code() reports such a row as
mapping_status == "out_of_span", and that column is dropped here so that
adding it does not change the schema of every area-keyed output at once.
polity_coverage_gaps() reports the stand-in rows of a built table, and
options(whep.polity_mapping_status = "flag") (or "status") carries the
signal on the outputs themselves. Both are opt-in; the default is no extra
column.
Examples
build_livestock_ghg_extension(example = TRUE)
#> # A tibble: 6 × 9
#> year area_code polity_area_code reporting_polity_code reporting_polity_name
#> <int> <int> <int> <chr> <chr>
#> 1 1986 10 10 AUS-1901-2025 Australia
#> 2 1986 10 10 AUS-1901-2025 Australia
#> 3 1986 10 10 AUS-1901-2025 Australia
#> 4 1986 100 100 IND-1949-2025 India
#> 5 1987 10 10 AUS-1901-2025 Australia
#> 6 1987 100 100 IND-1949-2025 India
#> # ℹ 4 more variables: reporting_polity_has_geometry <lgl>, item_cbs_code <int>,
#> # impact_u <dbl>, method_ghg <chr>