Skip to content

Commit 635727d

Browse files
h3-guide: strengthen cross-resolution join guidance to prevent h3_cell_to_children misuse (#40)
Closes #39 Co-authored-by: Carl Boettiger <cboettig@berkeley.edu>
1 parent 0850c74 commit 635727d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

h3-guide.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ SELECT APPROX_COUNT_DISTINCT(h5) * 252.9 AS area_km2 FROM ...
2929

3030
## Joining Different Resolutions
3131

32-
Datasets use different H3 resolutions. Use `h3_cell_to_parent()` to convert the **finer** resolution up to the **coarser** one before joining:
32+
Use `h3_cell_to_parent()` — not `h3_cell_to_children()` to join datasets at different resolutions. Always convert the **finer** (higher number) resolution to the **coarser** (lower number) resolution:
3333

3434
```sql
3535
-- dataset_a has h8, dataset_b has h4: convert h8 → h4
3636
JOIN dataset_b b
3737
ON h3_cell_to_parent(a.h8, 4) = b.h4
3838
AND a.h0 = b.h0 -- include h0 when both sides have it
39+
40+
-- WDPA (h8) + GFW fishing effort (h6): convert h8 → h6
41+
JOIN gfw ON h3_cell_to_parent(wdpa.h8, 6) = gfw.h6
42+
AND wdpa.h0 = gfw.h0
3943
```
4044

4145
When one side lacks h0, omit it from that side. Prefer hex-partitioned variants (with h0) when available for partition pruning.

0 commit comments

Comments
 (0)