question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Misaligned polygons, not perfect hexagons. Some pentagons. Catering for projection

See original GitHub issue

Hi,

Im trying to incorprate your library on a number of solutions which require realtime translations between hex ids and geojson multi/polygons.

h3.h3SetToMultiPolygon(["85291a6ffffffff"],true)

returns

[[[[-121.87310260648961,36.48355301296484],[-121.82059177712684,36.56646154014561],[-121.88144909358076,36.64149027277887],[-121.99481876336013,36.63355254199253],[-122.0471691328904,36.550641568925464],[-121.98631059624982,36.4756707384872],[-121.87310260648961,36.48355301296484]]]]

No problem with that. The issue however is displaying this now results in an askew/misrepresented polygon on a map.

image

The map is in EPSG:4326. Geojson.io

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "color": "blue"
      },
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -121.87310260648961,
                36.48355301296484
              ],
              [
                -121.82059177712684,
                36.56646154014561
              ],
              [
                -121.88144909358076,
                36.64149027277887
              ],
              [
                -121.99481876336013,
                36.63355254199253
              ],
              [
                -122.0471691328904,
                36.550641568925464
              ],
              [
                -121.98631059624982,
                36.4756707384872
              ],
              [
                -121.87310260648961,
                36.48355301296484
              ]
            ]
          ]
        ]
      }
    }
  ]
}

Is this correct?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
nrabinowitzcommented, Aug 3, 2019

This appears to be working as expected. In order to divide the world into stable cells that have low shape and area distortion, the H3 grid doesn’t work like a screen-based or local hex binning algorithm with screen-aligned hexagons.

Key issues to be aware of:

  • The alignment of the cells will change in different parts of the world.
  • Particularly at coarse resolutions, hexagons may appear distorted at northern or southern latitudes when shown on a Mercator projection (as in web maps). This is a function of the projection, not the H3 system.
  • H3 cells are not exactly equal size or equal area, though they have low shape and area distortion.
  • There are 12 pentagon-shaped cells at every resolution. These are centered in water, and can be ignored for many use cases.
  • Some cells (on the edges of the icosahedron used to create the grid) are subject to distortion, which adds additional vertexes on one or two edges. Hexagon cells (in the topological sense, with 6 neighbors) may have up to eight vertices, and pentagon cells may have 10.
0reactions
currancommented, Aug 6, 2021

Amazing! Thank you so much 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

H3 oddities / Fil - Observable
In H3, the spherical polygons are not directly defined on the sphere, but are drawn on a gnomonic projection of each face (centered...
Read more >
Hexagons are the Bestagons - YouTube
Behind the Scenes: https://www.youtube.com/watch?v=4R3N1oeKbE4‣ Hexagons are the Bestagons shirt: ...
Read more >
Love Quote 01 AI Acrylic Art - OpenSea
I saw that you were perfect, and so I loved you. Then I saw that you were not perfect and I loved you...
Read more >
Thematic Mapping with Hexagons - Esri
If you end up re-projecting your data, then bear in mind your hexagons will be distorted in terms of their shape and apparent...
Read more >
8054$$CH50 - Baen Books
You know perfectly well that I know ALL about him, Mentor. ... It's a small . . . shelf, projection, whatever, no more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found