Optional ergonomics — not a capability gap
(Reframed after discussion in data-workflows.) On reflection this is not a missing reducer: cng-datasets already handles per-area/density rasters correctly via --hex-resampling mean. Filing for the datasets team to assess two optional ergonomics improvements.
Background (data-workflows #202, resolved)
The Conservation International carbon rasters (Noon et al. 2022) store carbon as density, Mg C ha⁻¹, on a ~300 m WGS84 grid. They had been hexed with --hex-resampling sum, which produced a meaningless sum of densities ~6–7× below the true total (irrecoverable-2018: 21 Gt vs published 139 Gt).
The root cause was the reducer choice, not the tool. sum is only for values already integrated per pixel (e.g. GHS-POP persons/cell); a density is intensive and aggregates with mean, with the total being mean_density × cell_area.
What the tool already does right
--hex-resampling mean correctly yields the area-weighted mean density per H3 cell for a density raster. The correct total is then mean × H3 cell area (a query-time derivation, or bake it in downstream). No core capability is missing — we corrected all 10 carbon layers this way, and the decision rule ("read the source units; the reducer follows the units, not the conceptual quantity") is now documented in the data-workflows AGENTS.md.
Optional improvements for the datasets team to weigh
sum-on-density guardrail (low effort, high value): when --hex-resampling sum is used and the source band's units/metadata look per-area (ha, /ha, km-2, density, …), emit a warning — "summing a per-area density is usually wrong; did you mean mean (then × cell area for a total)?" This would have caught the carbon mistake automatically.
--density-to-total convenience (pure sugar): a flag emitting mean × exact H3 cell ground area, so a density→total product is one step and uses the exact per-cell area instead of a manual latitude approximation. Equivalent to today's mean + a downstream multiply.
Neither blocks anything — the correct path works today. The operator-decision safeguard lives in data-workflows AGENTS.md; this issue is only about optional tooling ergonomics.
Related: #95 (max/min — done), #88/#92 (seam geometry).
Optional ergonomics — not a capability gap
(Reframed after discussion in
data-workflows.) On reflection this is not a missing reducer:cng-datasetsalready handles per-area/density rasters correctly via--hex-resampling mean. Filing for the datasets team to assess two optional ergonomics improvements.Background (data-workflows #202, resolved)
The Conservation International carbon rasters (Noon et al. 2022) store carbon as density, Mg C ha⁻¹, on a ~300 m WGS84 grid. They had been hexed with
--hex-resampling sum, which produced a meaningless sum of densities ~6–7× below the true total (irrecoverable-2018: 21 Gt vs published 139 Gt).The root cause was the reducer choice, not the tool.
sumis only for values already integrated per pixel (e.g. GHS-POP persons/cell); a density is intensive and aggregates withmean, with the total beingmean_density × cell_area.What the tool already does right
--hex-resampling meancorrectly yields the area-weighted mean density per H3 cell for a density raster. The correct total is thenmean × H3 cell area(a query-time derivation, or bake it in downstream). No core capability is missing — we corrected all 10 carbon layers this way, and the decision rule ("read the source units; the reducer follows the units, not the conceptual quantity") is now documented in thedata-workflowsAGENTS.md.Optional improvements for the datasets team to weigh
sum-on-density guardrail (low effort, high value): when--hex-resampling sumis used and the source band's units/metadata look per-area (ha,/ha,km-2,density, …), emit a warning — "summing a per-area density is usually wrong; did you meanmean(then × cell area for a total)?" This would have caught the carbon mistake automatically.--density-to-totalconvenience (pure sugar): a flag emittingmean × exact H3 cell ground area, so a density→total product is one step and uses the exact per-cell area instead of a manual latitude approximation. Equivalent to today'smean+ a downstream multiply.Neither blocks anything — the correct path works today. The operator-decision safeguard lives in
data-workflowsAGENTS.md; this issue is only about optional tooling ergonomics.Related: #95 (max/min — done), #88/#92 (seam geometry).