Skip to content

Update average edge lengths - #749

Merged
ajfriend merged 2 commits into
uber:masterfrom
mciethan:master
Mar 23, 2023
Merged

ajfriend merged 2 commits into
uber:masterfrom
mciethan:master

Conversation

@mciethan

Copy link
Copy Markdown
Contributor

I recomputed average edge lengths for all H3 resolutions, building off of the proposed methodology and example notebook provided by @ajfriend in #666 (which involves calculating exact averages for resolutions 0 through 6 and then extrapolating the rest). This would help fix #526 and other issues related to average edge lengths.

Source notebook: https://gist.github.com/mciethan/3e10802c1f41972831c325994d97ef27

My initial commit to this PR only modifies the restable docs. I haven't attempted to modify the average edge length function itself, although it would make sense to do that before updating the docs. I assume that would just be a matter of updating the hard-coded values, but I am a novice of H3 and also don't know any C programming, so I don't have a good understanding of exactly which files would need to be updated, how to test the changes, etc.

Also added a sentence on methodology
@CLAassistant

CLAassistant commented Jan 31, 2023 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coveralls

coveralls commented Jan 31, 2023 •

Copy link
Copy Markdown

Coverage Status

Coverage: 98.657%. Remained the same when pulling 8e155a1 on mciethan:master into 03d6f3d on uber:master.

@nrabinowitz

Copy link
Copy Markdown
Contributor

This looks great, thanks for the contribution! I'll let @ajfriend check the approach here, but it LGTM. I believe you're correct that all we would need to do in code is modify the hard-coded values, feel free to add that to this PR.

@mciethan

mciethan commented Feb 6, 2023

Copy link
Copy Markdown
Contributor Author

Sounds good, I went ahead and updated the hard-coded average edge length values in my latest commit. I rounded all values to 10 significant digits, as the original code does.

@ajfriend

Copy link
Copy Markdown
Contributor

Looks good to me! And just as a quick sanity check, I made a plot with the interpolated values:

Screenshot 2023-03-23 at 2 20 06 PM

@ajfriend
ajfriend merged commit 71e09dc into uber:master Mar 23, 2023
grim7reaper added a commit to HydroniumLabs/h3o that referenced this pull request Jul 30, 2023
H3 reference implementation did the same in uber/h3#749

Couldn't test against it since it's not released yet (and thus
there is no h3ron_h3_sys that binds to it). Not a big deal since I
shouldn't exclusively rely on tests against H3 to ensure my correctness.

Instead I have a little tool (which is equivalent to the Python notebook
linked in the PR) that generated a golden file and I test against it.
zachasme added a commit to postgis/h3-pg that referenced this pull request Jan 2, 2025
The constant changes in tests are related to uber/h3#749
alexey-milovidov added a commit to ClickHouse/ClickHouse that referenced this pull request Mar 22, 2026
The H3 C library fork (github.com/ClickHouse/h3) was on v3.7.1 with
2 ClickHouse-specific range-check patches. Upstream H3 v4 already
includes equivalent validation in `_h3ToFaceIjk`, so the patches are
no longer needed.

Created a clean `clickhouse-v4` branch in the fork at upstream tag
v4.4.1 with no additional patches.

This fixes two known bugs in the v3 lookup tables:
- Average hexagon edge lengths were actually inradii (apothems), not
  edge lengths (uber/h3#201, fixed in
  uber/h3#749)
- Average hexagon areas naively divided Earth surface by total cell
  count without excluding pentagon areas (fixed in
  uber/h3#529)

The v4 API changed most functions to return `H3Error` with results via
output parameters. Updated all 27 wrapper files in `src/Functions/` to
use the new calling convention. Also updated function renames:
`exactEdgeLengthM` → `edgeLengthM`, `distanceM` →
`greatCircleDistanceM`, etc.

Updated 11 test reference files to reflect the corrected values.

Reference: #100272

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
dvanduzer added a commit to tennica/hexmosphere that referenced this pull request Oct 22, 2026
H3 C 4.1.0 still had the old average edge-length table, about 13%
smaller; H3 replaced it in March 2023 (uber/h3#749). With v4.5.0 the two
backends match on edge lengths at every resolution (within a millionth
of a metre) as well as on cells and outlines (100,000 random points at
resolutions 7, 9 and 11). The README and the switch's help now say they
agree, and note the earlier mistake.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MHdRua2oBLtZHVW7Q9BrjH
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.

Average Hexagon Length value incorrect in restable

6 participants