Skip to content

After #619 the spatialize loaders still read the centroid pin the same PR makes the engine refuse #696

Description

@lbm364dl

PR #619 (edu/polycell-spatial-support) reports its spatialize movement as
"zero — enforcement only", and that is accurate about the engine: commit
de9867a6 turns .normalize_country_grid()'s missing-share default into an
abort, removes landfrac from the alias list, and makes
.compartment_join_cols() refuse to degrade to a (lon, lat) join.

What it does not do is change which table the engines are fed. On that
branch, R/run_spatialize.R is a 3-line docs-only diff, and
.load_landuse_inputs() / .load_livestock_inputs() still read the
spatialize-country-grid pin — a 58,795-row centroid grid with lon, lat,
area_code and no share column. That is exactly the input the same PR
teaches the engine to abort on, so once #619 lands,
run_spatialize() against the deployed pin aborts at
.normalize_country_grid().

Two things have to meet for that not to happen:

  1. A grid with a share column has to be reachable from the loaders. Feed crop/livestock spatialize the fractional cell-coverage grid, not the centroid grid #461
    added the seam: .load_country_grid(input_dir, source) in
    R/run_spatialize.R, selected by
    run_spatialize(overrides = list(country_grid = ...)), today "centroid"
    (default) or "fraction". Adding "polycell" is one branch plus a reader —
    build_polycell_support() / read_polycell_support() on that branch — and
    the resolved choice already lands in run_metadata.yaml.
  2. The polycell pin has to exist. inst/extdata/whep_inputs.csv on that
    branch carries polycell_support with an empty version, so it is
    declared and not uploaded.

Also worth wiring at the same seam: the polycell is keyed on polity_code, not
area_code, while both spatialize engines allocate from national tables keyed
on area_code. #619's own body says "consumers convert at their own boundary",
so that conversion belongs in .load_country_grid(), where it is visible at a
join, rather than inside the engine.

Acceptance criteria

  • run_spatialize(overrides = list(country_grid = "polycell")) runs end to end.
  • The default path is unchanged, or changed deliberately with the movement
    measured per the epic's grid note (per-(country, crop, year) L1 over
    normalised cell-share vectors, plus the change in compartments receiving an
    allocation — a totals diff proves nothing, because R/spatialize.R rescales
    back to the national target).
  • .warn_grid_missing_reporters() (Feed crop/livestock spatialize the fractional cell-coverage grid, not the centroid grid #461) reports no new deleted reporting area
    under the polycell than under the centroid grid.

Depends on: #619 landing, and the polycell_support pin being uploaded.
Moves published values: only if the default is changed.

Part of the polity migration epic #458.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:data-ioData inputs, pins, reading, scrapingarea:spatializeSpatial disaggregationbugSomething isn't workingmechanicalNo methodological decision; objectively correct. Reviewable on tests/CI, low-review to merge.priority:highWe want to get this done soon

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions