Skip to content

feat(processes): population-weighted aggregation to features - #28

Merged
turban merged 3 commits into
mainfrom
feat/population-weighted-aggregation
Oct 21, 2026
Merged

turban merged 3 commits into
mainfrom
feat/population-weighted-aggregation

Conversation

@turban

@turban turban commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the package's first openEO process, aggregate_spatial_population_weighted: the population-weighted mean of a raster per feature and time step, sum(value × population) / sum(population), with a population raster such as WorldPop as weights.

It is moved unchanged from the Sri Lanka and Salvador instances, so any instance can install it; the workflow that saves Chap CSV stays in those instances for now. The process is renamed from aggregate_spatial_weighted: under that name it replaced OCS core's area-weighted process, which takes different arguments, so core workflows such as aggregate_by_features failed on those instances.

It counts a cell when its centre is inside the feature, unlike core's coverage-weighted aggregation. The README says so, and that the population raster should be much finer than the smallest feature.

Tests: discovery through the entry point, the weighted mean against a hand-computed value, and cells with no data or no people left out, with a feature without any getting no value rather than 0.

An openEO process, aggregate_spatial_population_weighted, and the
aggregate_population_weighted_chap workflow, moved here from the Sri Lanka and Salvador
instances so any instance can install them. Named apart from core's area-weighted
aggregate_spatial_weighted, which the instance copies used to shadow.
Only the process moves here for now; the workflow that saves Chap CSV stays with the
instances that use it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Population resampling and grid-order handling can produce incorrect aggregation results.

3 open issues
What changed in this PR

Adds a reusable population-weighted aggregation process to OCS plugins, using a distinct name to avoid replacing core’s area-weighted process.

Changes:

  • Introduces per-feature, per-time-step population-weighted means.
  • Tests process discovery, weighted calculations, and missing values.
  • Documents process availability and aggregation behavior.
File Description
tests/​test_population_weighted.py Tests discovery and aggregation behavior.
README.md Documents the process and grid-resolution guidance.
ocs_plugins/​processes/​aggregate_spatial_population_weighted.py Implements population-weighted aggregation.
ocs_plugins/​processes/​__init__.py Adds the processes package.
ocs_plugins/​__init__.py Updates the package docstring to mention processes.

Review effort: Balanced

@turban
turban merged commit 3974d55 into main Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants