With the battle in Iran inflicting worldwide disruption to power markets, I’ve each a piece and private curiosity in power provide in Pacific islands, which led me to this weblog put up. Right here I have a look at simply two facets of power: electrical energy technology, and family cooking. Nothing fancy right here, simply accessing some knowledge and drawing a few plots.
Electrical energy technology
Right here is the supply of electrical energy for Pacific island international locations, plus Australia and New Zealand, collated by Our World In Information from Vitality Institute knowledge that in the end comes from authorities estimates:
There’s a fairly apparent story right here: many of the Pacific is very depending on “oil” (within the type of diesel) for technology of most of its electrical energy. There are some small steps in the direction of renewables occurring in recent times, however the vulnerability to a worth or availability shock for diesel is fairly apparent.
Right here’s the code for producing that, utilizing the precious owidapi R bundle to entry the Our World in Information API.
#---------------Arrange-----------------
library(owidapi)
library(tidyverse)
library(countrycode)
library(WDI)
library(jsonlite)
library(janitor)
library(httr2)
pic_codes <-
c(
"ASM", "COK", "FSM", "FJI", "PYF", "GUM", "KIR", "MHL", "NRU", "NCL",
"NIU", "MNP", "PLW", "PNG", "PCN", "WSM", "SLB", "TKL", "TON", "TUV",
"VUT", "WLF", "AUS", "NZL"
)
stopifnot(size(pic_codes) == 24)
# visible test we have the fitting nation codes for the Pacific:
countrycode::countrycode(pic_codes, origin = "iso3c", vacation spot = "nation.title.en")
#=======================electrical energy supply===================
palette <- c(
coal = "brown",
fuel = "magenta",
oil = "crimson",
kerosene = "crimson",
electrical energy = "purple",
photo voltaic = "yellow",
wind = "steelblue",
hydro = "darkblue",
bioenergy = "lightgreen",
charcoal = "gray",
biomass = "darkgreen",
'different renewables' = "darkgreen"
)
#-------------------electricity mix-----------------
elec_mix <- owid_get(
chart_id = "share-elec-by-source",
entities = pic_codes
)
elec_data <- elec_mix |>
rename(nation = entity_name) |>
choose(-entity_id) |>
collect(variable, worth, -nation, -yr) |>
filter(worth != 0) |>
filter(yr > 2001) |>
mutate(variable = gsub("_share_of_electricity__pct", "", variable, mounted = TRUE),
variable =gsub("_", " ", variable),
variable =gsub(" excluding bioenergy", "", variable),
variable = fct_drop(variable)) |>
mutate(variable = fct_relevel(variable, c("bioenergy", "hydro", "different renewables"), after = Inf)) |>
mutate(nation = fct_relevel(nation, c("Australia", "New Zealand"), after = Inf)) |>
group_by(nation) |>
mutate(prop_pc= sum(worth[variable %in% c("oil", "gas") & year == max(year)])
/ sum(worth[year == max(year)])) |>
ungroup() |>
mutate(nation = fct_reorder(nation, prop_pc))
# Draw chart
elec_data |>
ggplot(aes(x = yr, y = worth, fill = variable)) +
facet_wrap(~nation, ncol = 5) +
geom_col() +
scale_fill_manual(values = palette) +
scale_y_continuous(label = percent_format(scale = 1)) +
labs(y = "Proportion of electrical energy",
fill = "Supply:",
title = "Share of electrical energy by supply",
subtitle = "Nations proven in rising order of vulnerability of electrical energy to a petrochemicals worth or availability disaster.",
x = "",
caption = "Supply: Ember (2026); Vitality Institute - Statistical Assessment of World Vitality (2025). Information processed by Our World In Information.") +
theme(axis.textual content.x = element_text(angle = 45, hjust = 1))
Cooking gas
OK, so electrical energy technology might be threatened by an absence of diesel. What about family cooking? This subsequent chart attracts on the definitive World Well being Group Family Vitality Database, which fashions (primarily based on what family survey knowledge that’s obtainable) what households are utilizing to prepare dinner:
Once more, we see numerous reliance on petrochemical merchandise, significantly kerosene and liquid pure fuel. The latter has been promoted as a comparatively clear and wholesome gas to prepare dinner with in comparison with burning biomass (e.g. wooden, coconuts, and so forth).
The bigger Melanesian international locations, with excessive rural populations, are these with the best use nonetheless of biomass for cooking. Most Pacific island international locations do most of their cooking with oil or fuel derived power (remembering from the primary chart, that ‘electrical energy’ typically means diesel, in the end).
Right here’s the code to supply that chart. I used an LLM (I overlook which) for the code to entry the API itself, however I examined it and tweaked it to match my type, and the chart in fact is all my very own code.
#--------------------cooking-------------------
# The definitive supply is the WHO WHO Family Vitality Database
# which attracts on varied family surveys
# See https://www.who.int/knowledge/gho/knowledge/themes/air-pollution/cooking-fuel-and-technology-database-by-fuel-category
# subsequent half dozen traces of code had been equipped by Co-pilot and minimally
# tweaked by me for my type
indicator_code <- "PHE_HHAIR_PROP_POP_CATEGORY_FUELS" # % by gas sort [3](https://millenniumindicators.un.org/wiki/areas/SDGeHandbook/pages/35291272/Indicator+7.1.2)
url <- paste0("https://ghoapi.azureedge.web/api/", indicator_code)
resp <- request(url) |>
req_headers(`Settle for` = "software/json") |>
req_perform()
cooking_data <- fromJSON(resp_body_string(resp), flatten = TRUE)$worth |>
as_tibble() |>
clean_names()
pic_cooking_data <-cooking_data |>
filter(spatial_dim %in% pic_codes) |>
filter(dim1 == "RESIDENCEAREATYPE_TOTL") |>
mutate(fuel_type = tolower(gsub("HOUSEHOLDCOOKINGFUEL_FUEL_", "", dim2))) |>
mutate(yr = as.numeric(time_dimension_value)) |>
choose(worth = numeric_value,
iso3_code = spatial_dim,
worth = numeric_value,
yr,
fuel_type) |>
mutate(nation = countrycode(iso3_code, origin = "iso3c", vacation spot = "nation.title.en"),
nation = gsub("Federated States", "Fed St", nation)) |>
group_by(nation) |>
mutate(prop_gke = sum(worth[fuel_type %in% c("gas", "kerosene", "electricity") & year == max(year)])
/ sum(worth[year == max(year)])) |>
ungroup() |>
mutate(nation = fct_reorder(nation, prop_gke))
# Draw chart
pic_cooking_data |>
ggplot(aes(y = worth, x = yr, fill = fuel_type)) +
facet_wrap(~nation, ncol = 5) +
# the numbers do not add as much as 100 all the time, as a result of being modelled estimates
#, not absolutely MECE, not counting twin fuels, and so forth. Good apply recommendation
# is to not pressure them so as to add to 100%
geom_area() +
scale_fill_manual(values = palette) +
scale_y_continuous(label = percent_format(scale = 1)) +
labs(title = "Family main gas used for cooking",
subtitle = "Estimates are modelled by WHO, and never including as much as 100% is a identified limitation.
Nations proven in rising order of vulnerability of cooking to a petrochemicals worth or availability disaster.",
x = "",
fill = "Gas sort:",
y ="Proportion of households",
caption = "Supply: WHO Family Vitality Database")
That’s all, only a fast one at this time.
