The UNFCCC provides access to National Inventory Reporting (NIR), World Bank and Compilation and Accounting (CAD) data through its Data Interface. Information on data availability is given here, with the most current observations from 27 September, 2022 (as of 12 January, 2023).
The flex query API allows programmatically downloading NIR and World Bank data.
See the API's documentation for additional information at https://unfccc.int/process-and-meetings/transparency-and-reporting/greenhouse-gas-data/data-interface-help,
but note this refers to the GUI implementation.
The Flex Query API is made available in remis
through flex_query()
.
Downloads require a combination of id
values for:
Parties
Years
Variables
The corresponding steps for querying are then:
Identify a party of interest in
rem_init()
$parties
, and note whether it is Annex-One or Non-Annex-One, and extract theid
.Choose (a subset of) years based on the Annex-One or Non-Annex-One party in
rem_init()
$years
.Select variables from
rem_init()
$variables
based on based on the Annex-One or Non-Annex-One party. A helper functionselect_varid()
allows narrowing down based on reporting categories, classifications, measures, units and gasses (ccmug's). Seeselect_varid()
for more information. Selected variables can be contextualized further by usingget_variables()
, which provides text representations of ccmug id's.
Usage
flex_query(
rms,
variable_ids,
party_ids,
year_ids,
path = "api/records/flexible-queries/",
pretty = TRUE
)
Arguments
- rms
list, object from
rem_init()
.- variable_ids
numeric,
variableId
s of interest- party_ids
numeric,
partyId
s of interest- year_ids
numeric,
yearId
s of interest- path
character, default is 'api/records/flexible-queries/'
- pretty
logical, should
id
s be transformed to text descriptions?
Value
data.frame with several id
columns (either text or integers), and
results as number_value
or string_value
.
Examples
# \donttest{
rem <- rem_init()
#> parsing api/parties/
#> parsing api/years/single
#> parsing api/dimension-instances/category
#> parsing api/dimension-instances/classification
#> parsing api/dimension-instances/measure
#> parsing api/dimension-instances/gas
#> parsing api/conversion/fq
#> parsing api/variables/fq/annexOne
#> parsing api/variables/fq/nonAnnexOne
cat1A1a <- rem$categories$annexOne[grepl("1.A.1.a.", rem$categories$annexOne$name), ]
# manually choose id
# cat1A1a$id[1]
# get variables
cat1A1a_variables <- get_variables(
rms = rem,
select_varid(
vars = rem$variables$annexOne,
cat1A1a$id[1])$variableId
)
#choose id:
var_id <-
subset(cat1A1a_variables,
classificationId == 'Total for category',
measureId == 'Aggregate GHGs'
)$variableId
# download data
cat1A1a_agg_ghg <- flex_query(
rms = rem,
variable_ids = var_id,
party_ids = 13, # Germany
year_ids = rem$years$annexOne$id)
#> Error in flex_query(rms = rem, variable_ids = var_id, party_ids = 13, year_ids = rem$years$annexOne$id): Please provide numeric id's for: variableIds
# }