build_h3_maps: Build H3 hierarchy maps for multiscale planning units

View source: R/h3_hierarchy.R

build_h3_mapsR Documentation

Build H3 hierarchy maps for multiscale planning units

Description

Creates basic parent–child relationships for a multiresolution H3 planning-unit dataset. This is the core structure used by all cross-scale operations.

Usage

build_h3_maps(s_or_h3, res_vec = NULL, res_levels = NULL)

Arguments

s_or_h3

Either an sf object with h3_address and res columns, or a character vector of H3 indexes.

res_vec

Optional integer vector of resolutions if s_or_h3 is not an sf.

res_levels

Optional integer vector of reporting resolutions.

Value

A list with elements h3_vec, res_vec, res_levels, row_idx_by_h3, nearest_parent_row_of, and children_by_row.

Examples

# Minimal example: two resolutions, parent-child relationship
h3_child  <- "8a2a1072b59ffff" # example H3 index
h3_parent <- "872a1072bffffff"

maps <- build_h3_maps(
  s_or_h3  = c(h3_parent, h3_child),
  res_vec  = c(7L, 8L),
  res_levels = c(7L, 8L)
)

str(maps, max.level = 1)
maps$nearest_parent_row_of


MultiscaleSCP documentation built on March 30, 2026, 5:08 p.m.