What is the best way to get the actual size of an H3 hexagon (area or edge length) given an H3Index
and not the average constant provided by the H3 API?
Asked
Active
Viewed 1,064 times
1

lurning too koad
- 2,698
- 1
- 17
- 47
1 Answers
3
Update: H3 now includes functions for exact area and edge length measurements - documentation here.
Original Answer:
At present, the H3 library doesn't expose any functions for this (though we've considered it, and may add in the future). At present, we've decided that the H3 library is no better placed to calculate pure geographic areas/distances/etc than any other geo library, so the best option is to find another geo library in your language of choice and apply it to the output of h3ToGeoBoundary
.
You can see an example of doing this in JavaScript in this Observable notebook.

nrabinowitz
- 55,314
- 10
- 149
- 165
-
I decided to use the `GeoBoundary` struct to make the calculation manually; you're right about there not really being a need for it since this is possible. I just posted a question about it, however. – lurning too koad Mar 17 '20 at 18:09
-
your link in update section is broken – Kamil Kiełczewski Jan 17 '22 at 19:25
-
@kidcoder Thanks, fixed – nrabinowitz Jan 17 '22 at 19:52
-
I get allways zero value for `h3.exactEdgeLength("8c29a1d756b49ff", (
h3).UNITS.m);` - (for any hex) may be you know why? (I use typescript and h3 by `import * as h3 from 'h3-js';` - it has some problem with UNITS but even if I type string "m" it still returns ZERO) - ? – Kamil Kiełczewski Jan 17 '22 at 20:04 -
1`h3.exactEdgeLength` takes a unidirectional edge, not a cell index. See https://h3geo.org/docs/api/uniedge – nrabinowitz Jan 17 '22 at 20:19
-
@nrabinowitz - oh - now I see - thank you :) – Kamil Kiełczewski Jan 17 '22 at 20:24