Skip to content

Inf-3: list_country_shapes() — return tibble of available countries and admin levels from bundled registry #147

Description

@EBukin

What to build

A new exported function list_country_shapes() that reads inst/wb_shapes_registry.yaml (Inf-2) and returns a tibble of available countries and admin levels. Parallel in design to the existing list_hex_vars().

Offline-capable — no network call. The deployer calls this at the start of 01-shapes.qmd to discover what ISO-3 codes and admin levels are queryable via get_country_shapes().

Signature and return value

list_country_shapes()

Returns a tibble with one row per (country × admin level):

Column Type Notes
iso3 character ISO-3 country code
country_name character English country name
admin_level integer 0, 1, or 2
level_name character Human-readable label, e.g. "Province", "District"
available logical TRUE if present in parquet
last_updated Date Date of last ETL run for this country

Usage in template

# Browse all available countries
list_country_shapes()

# Filter to a specific country
list_country_shapes() |>
  dplyr::filter(iso3 == "RWA")

# Find all countries with admin2 coverage
list_country_shapes() |>
  dplyr::filter(admin_level == 2, available)

Implementation notes

  • Reads bundled YAML via internal read_shapes_registry()
  • No network dependency
  • @family data-input (same family group as list_hex_vars())
  • Roxygen examples must pass devtools::check() without network access

Acceptance criteria

  • list_country_shapes() is exported and documented
  • Returns one row per (iso3 × admin_level)
  • Works offline (no HTTP calls)
  • devtools::check() examples pass headlessly
  • Unit test: returns a tibble with correct columns; Rwanda rows present; result is filterable

Blocked by

#146 (Inf-2) — requires the registry YAML to be present.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions