
Cheat sheet: Spatial resolution
Source:vignettes/articles/cheatsheet-space.Rmd
cheatsheet-space.RmdRegions 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-29A 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.
gg_geoscale(gs, type = "icicle", weight = "km2")mod <- newModel("demo", geoscale = gs,
region = c("R1", "R2", "R3", "R4"))
mod <- setGeoscale(mod, gs) # or laterA real one, drawn
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 nationGeoscale functions
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"))
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.
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.process_cluster_sweep(object, group, ks, …)Dispersion and silhouette over a range of k, to choose by looking.
Maps of results
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.