fix(#364): coarse-overlay example weights by land_area_km2, not the removed nland - #365
Merged
Merged
Conversation
…and grid The res-8/res-9 weights assets no longer carry nland (data-workflows#524), so the coarse-resolution overlay example was a binder error, not a wrong number. Take the weight from the region's land-grid rollup (ca30x30-ecoregion, ecoregion-hex-res9/-res8), which publishes an exact per-cell land_area_km2 — same 26.135% statewide as the res-10 ground truth, and the form the -hex-weights-res9/-res8 asset descriptions already document. The land grid is joined for the weight, so it is also the denominator and the land bound; the h3_cell_area() call goes away. Res-9 and the hex-fractions variant drop to prose.
This was referenced Aug 8, 2026
Member
Author
|
Verified against live data before merge — this is the check that would have caught #364, and it is not something the regression tier can currently do (geo-agent-benchmark#21). Running this PR's recipe statewide, against the res-10 ground truth for the same scope: -- this PR's recipe at res 8
WITH feat AS (SELECT DISTINCT h8, h0 FROM read_parquet('s3://public-ca30x30/ecoregion/hex-res8/h0=*/data_0.parquet'))
SELECT 100 * SUM(COALESCE(p.w1 + p.w2, 0) * e.land_area_km2) / SUM(e.land_area_km2)
FROM feat f
JOIN read_parquet('s3://public-ca30x30/ecoregion/hex-res8/h0=*/data_0.parquet') e USING (h8, h0)
LEFT JOIN read_parquet('s3://public-ca30x30/conserved-areas-terrestrial-2025/hex-weights-res8/h0=*/data_0.parquet') p USING (h8, h0);
-- 26.135
Exact to three decimals. It also drops the Ready to merge from my side. Next: tag v0.8.14 and promote by digest — #362 (promote v0.8.13) is closed as superseded, since v0.8.13 carries the #364 break. Coordination note: further edits to this block are sequenced under #367, behind the gate-coverage work, so this should be the last patch here before that design pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #364.
h3-guide.md's coarse-resolution overlay example readnlandfrom the…-hex-weights-res8/-res9assets. data-workflows#524 removed that column (2026-08-07, an hour after #357), so the example was a
hard SQL error on any res-8/res-9 question:
Source fix, not a method change: the weight now comes from the region's land-grid rollup
(
ca30x30-ecoregion, assetsecoregion-hex-res9/-res8), which publishes an exact per-cellland_area_km2— the summed area of the actual res-10 land children rather than a count times theparent's area. That is also verbatim the form the
-hex-weights-res9/-res8asset descriptionsdocument, so the injected guide and the per-dataset text stay on the same form (the point of #357).
Verified against prod
Statewide GAP 1+2 at res 8, with the new block:
matching the res-10 ground truth (26.135%) and the
nland × h3_cell_areaproduct the guide used toname. Also ran the filtered three-table shape as written (Mojave Desert as a res-8 feature): 44.87%
at res 8 against 44.70% at res 10 — the residual is the coarse feature's own footprint spill, which
is inherent to asking at res 8, not a weighting error.
The two res-8 assets are 1:1 over the same footprint (525,034 rows each, zero land cells without a
weights row), so the
LEFT JOIN+COALESCEis defensive here and load-bearing at res 10.One deviation from the issue's suggested diff
#364 proposes a three-line block with a bare
WHERE <feature filter>and no feature table. Thatwould not bind — the section's premise is a coarse feature overlaid on a finer layer, so the
feature has to be in the query. I kept the
featCTE from the current block and joined the land gridto it:
Everything else follows the issue: line 318's rule names
land_area_km2and the land-grid assets,line 331 becomes "the land grid is both the weight and the denominator", and the res-9 /
fracvariants at line 336 drop to prose. Net: one fewer inline formula, same number of SQL blocks.
Relation to #362
#362 (prod v0.8.12 → v0.8.13) would ship the broken section, so it should take this commit and
re-gate. Its green gate exercised the res-10 path (CWHR13 percent-conserved), which is unaffected —
it never touched the broken branch. A gate cell asking a res-8 or res-9 feature question would.