Skip to contents

Regions and their hierarchy (geoscale): where commodities balance, where processes sit, and how to coarsen or cut a model

PDF, A4, one page · energyRt 0.91.5.9015 (dev) · 2026-11-29
A geoscale
library(geoscales)
gs <- geoscale_from_leaftable(
  data.frame(
    nation = c("NA1", "NA1", "NA2", "NA2"),
    province = c("R1", "R2", "R3", "R4"),
    km2 = c(3, 2, 4, 1)),
  geoframes = c("nation", "province"),
  weights = "km2", default_weight = "km2",
  name = "demo")
One row per finest region, one column per level, coarse to fine.
Icicle plot of the demo geoscale, nations above provinces
gg_geoscale(gs, type = "icicle", weight = "km2")
mod <- newModel("demo", geoscale = gs,
  region = c("R1", "R2", "R3", "R4"))
mod <- setGeoscale(mod, gs)   # or later
A real one, drawn
TOPIA's island geoscale, nation over zones over provinces
gg_geoscale(topia$geoscales$island, type = "stack", view = "oblique", depth = 1)

A model's region vector is its finest resolution. The geoscale adds the levels above it -- it makes coarser cells available, it does not coarsen the model.

Who sits where
commodity geoframe = -- the level it is balanced at; coarser = free, lossless transport inside each cell
process region = -- any level: a regional mill can feed a national balance, never a finer one
supply, demand, storage, import, export, weather -- a level compatible with their commodity
trade -- routes between cells of one level: congestion, cost and loss need it
ELC <- newCommodity("ELC")      # per province
STL <- newCommodity("STL",
  geoframe = "nation")         # per nation
Geoscale functions
setGeoscale(obj, geoscale, ...)
Attach a hierarchy to a model or scenario.
get_region(object)
The regions of a model.
check_geoscale_regions(geoscale, region, level)
Do these regions belong to this level?
check_model_levels(object)
Every object's level against its commodities' -- before interpolation.
plot_geoscale(object, type, geoframe, …)
"stack", "icicle", maps of one level.
Three ways to change resolution
study a part in full detail -- subset_model_regions(): drops regions and the routes leaving them
solve all of it, coarser -- aggregate_model_regions(): fine regions become coarse cells
coarser, keeping variety -- aggregate_model_regions(clusters =): k process archetypes per cell

Aggregation is lossy: a coarse balance is a copperplate the fine model did not have. Compare with a fine benchmark.

Cut out a part
subset_model_regions(object, region, boundary_prices, …)
A sub-territory; boundary_prices = gives severed routes a priced stub instead of an edge.
west <- subset_model_regions(mod,
  region = c("R02", "R03"))
is_separable(object, region, …)
Is the cut exact -- does nothing cross it?
solve_by_region(object, name, regions, trade, …)
Cut, solve and store each region in turn.
Coarsen
ELC <- newCommodity("ELC")
mini <- newModel("MINI",
  region = c("R02", "R03"),
  calendar = calendars$annual,
  horizon = horizons$Y2020_2060_by_5,
  repo = newRepository("r", ELC))
zones <- aggregate_model_regions(mini,
  geoscale = topia$geoscales$squares,
  level = "zone")
get_region(zones)
R02 and R03 roll up into the zone they share.
aggregate_model_regions(object, geoscale, level, clusters, …)
Returns a model on the coarse regions, with the pruned geoscale.
verify_aggregation(fine, coarse, tol)
What the aggregation conserved: totals of capacity, demand, resource.
model_clusters(object)
The clustering behind an aggregated model.
Keep variety: clusters
get_process_groups(mod)
aggregate_model_regions(mod,
  level = "zone",
  clusters = list(
    ECOA = list(k = 3,
      features = c("invcost", "eff")),
    EWIN = 8))
Per technology family, never one k for the model; k = "auto" takes the best silhouette.
get_process_groups(x, regions)
Families of the same structure -- what can merge.
process_cluster_sweep(object, group, ks, …)
Dispersion and silhouette over a range of k, to choose by looking.
Maps of results
gg_map(object, type, level, comm, year, …)
Results by region on the map, at any level.
gg_trade_map(object, map, level, …)
Routes and flows between regions.
gg_map(scen, type = "capacity",
       level = "zone", comm = "ELC")
Pitfalls
  • A process cannot produce into a finer balance than its own location: the destination would be ambiguous.
  • A cost declared once on a coarse cell does not shrink when only some of its child regions are kept.
  • A coarse commodity balance is free transport inside the cell -- never use it for a network-constrained carrier like electricity.
  • "Cluster" here groups regions; process clusters (Clusters & vintages) are another thing.