1

The H3 library uses a Dymaxion orientation, which means that the hexagon grid is rotated to an unusual angle relative to the equator/meridian lines. This makes sense when modelling the Earth, as the twelve pentagons then all lie in the water, but would be unnecessary when using the library to map other spheres (like the sky or other planets). In this case it would be more intuitive and aesthetically pleasing to align the icosahedron to put a pentagon at the poles and along the meridian. I'm just trying to work out what I would need to change in the library to achieve that? It looks like I would need to recalculate the faceCenterGeo and faceCenterPoint tables in faceijk.c, but do I need to recalculate faceAxesAzRadsCII as well? I don't really understand what that latter table is...

Stephen
  • 1,657
  • 13
  • 10
  • This feels like a borderline-appropriate question for SO, but the maintainers at https://github.com/uber/h3 seem keen to funnel questions here rather than the Github issues list... – Stephen Aug 02 '21 at 19:18
  • I agree that it's borderline, and I won't vote to close, but in general who sends you here doesn't make a difference to what's on topic, as discussed at https://stackoverflow.com/help/product-support – IMSoP Aug 02 '21 at 19:23
  • As an H3 maintainer, I think this is SO-appropriate, though we'd accept it in GH issues as well. It's clearly a "How do I?" question, which the docs page @IMSoP links to describes as appropriate content for SO. – nrabinowitz Aug 05 '21 at 21:17

1 Answers1

3

Per this related answer, the main changes you'd need for other planets are to change the radius of the sphere (only necessary if you want to calculate distances or areas) and, as you ask, the orientation of the icosahedron. For the latter:

  • faceCenterGeo defines the icosahedron orientation in lat/lng points
  • faceCenterPoint is a table derived from faceCenterGeo that defines the center of each face as 3d coords on a unit sphere. You could create your own derivation using generateFaceCenterPoint.c
  • faceAxesAzRadsCII is a table derived from faceCenterGeo that defines the angle from each face center to each of its three vertices. This does not have a generation script, and TBH I don't know how it was originally generated. It's used in the core algorithms translating between grid coordinates and geo coordinates, however, so you'd definitely need to update it.

I'd strongly suggest that taking this approach is a Bad Idea:

  • It's a fair amount of work - not (just) the calculations, but recompiling the code, maintaining a fork, possibly writing bindings in other languages for your fork, etc.
  • You'd break most tests involving geo input or output, so you'd be flying blind as to whether your updated code is working as expected.
  • You wouldn't be able to take advantage of other projects built on H3, e.g. bindings for other languages and databases.

If you want to re-orient the geometry for H3, I'd suggest doing exactly that - apply a transform to the input geo coordinates you send to H3, and a reverse transform to the output geo coordinates you get from H3. This has a bunch of advantages over modifying the library code:

  • It's a lot easier
  • You could continue to use the maintained library
  • You could apply these transformations outside of the bindings, in the language of your choice
  • Your own code is well-separated from 3rd-party library code

There's probably a very small performance penalty to this approach, but in almost all cases that's a tiny price to pay compared to the difficulties you avoid.

nrabinowitz
  • 55,314
  • 10
  • 149
  • 165