H3: A Hexagonal Hierarchical Geospatial Indexing System
I used to work at Uber and worked on H3. They&#x27;re working on a blog post to explain some more, but if you clone the repo and build the doxygen docs, you&#x27;ll get more explanation.<p>The big difference between this and S2 is that hexagons have only one kind of neighbor, neighbors that border on an edge, instead of the two kinds of &quot;checkerboard&quot; neighbors that squares have. This lets you do some interesting analysis on data gathered with hexagons.<p>Movement between neighbors could be modelled as a current flow, with the edge being a cross-sectional area between them, and since the edges are all equal (unlike squares) you can consider it a constant factor on that analysis, and then drop it and simply use the directional flow counts (the H3 UniEdge index) directly.<p>H3 takes better care than S2 to keep both hexagon area and shape distortion to a minimum together (area distortion is about the same as S2, but shape distortion is much better than S2), so the hexagons look almost the same almost anywhere on the planet, and so data gathered in one city on the planet is directly comparable to data gathered in another city, which can let you do interesting things like classify &quot;types&quot; of hexagons (urban, suburban, etc) and then make predictions about cities you haven&#x27;t even set up shop in, yet, based on similar cities.<p>Hexagons are also the most efficient way to pack spheres, and can best approximate a circular radius with a discrete grid, so they&#x27;re also useful for doing fast approximations of field-effect calculations (like electromagnetic fields from discrete particles). You could count drivers as a negative charge and riders as a positive charge, for instance, and use EM equations to determine the biggest imbalances in supply and demand distribution, and this will let you do it very quickly with little error.<p>The hexagons themselves can get down to a granularity below GPS resolution error, so you could, without any effective losses, pack 3 doubles (lat, lng, error) into a single 64-bit integer (H3 index of an appropriate size based on the error) and reduce bandwidth usage on location data.<p>The H3 index for any particular resolution is ordered in something similar to a Gosper curve[1] so if you really need just a rough approximation of data to query from an area, you actually only need to store the two indexes at the beginning and end of the gosper-like curve you&#x27;re interested in.<p>This C library wasn&#x27;t meant to be used directly by most developers and that&#x27;s why it has a few rough edges (like not centering the output around the meridian (-180, 180) instead of the current (0, 360) output). I can&#x27;t wait until the bindings come out, too, probably with the blog post. :)<p>[1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Gosper_curve" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Gosper_curve</a>