7 ms·
H3: A Hexagonal Hierarchical Geospatial Indexing System
- macmccann 9y agoFor anyone else wondering, like I did, why you would use a hexagonal indexing system instead of a (roughly square) latitude longitude system, from https://eng.uber.com/elk/ https://eng.uber.com/elk/: "Data size matters in Elasticsearch; a large index means too much data, caching churn, and poor response time. When query volumes are large, ELK nodes become overloaded, causing long garbage collection pauses or even system outages. To address this, we switched to hexagonal queries, dividing our maps into hexagonal cells. Each hexagonal cell has a string ID determined by the hexagon resolution level. A geodistance query can be roughly translated to a ring of hexagon IDs; although a hexagonal ring is not a circular surface, it is close enough for our use case. Due to this adjustment, our system’s query capacity more than tripled."
- deleted 9y ago[deleted]
- dvanduzer 9y agoFor those interested in the variety of uses for hexagonal / hierarchical indexing, Dr. Kevin Sahr at Southern Oregon University has produced an open specification and a number of ancillary research around the topic: http://www.discreteglobalgrids.org/information/ http://www.discreteglobalgrids.org/information/ There are several options for partitioning your grid, and the geometric consequences on your index. This overview in particular should be accessible even without a deep GIS background: http://webpages.sou.edu/~sahrk/sqspc/pubs/xuzhouKeynote13.pdf http://webpages.sou.edu/~sahrk/sqspc/pubs/xuzhouKeynote13.pd...
- elihu 9y agoThat's interesting. It looks like the ideas are similar to a Haskell library I wrote awhile back to tile a sphere with hexagons (and a few pentagons): https://wiki.haskell.org/IcoGrid https://wiki.haskell.org/IcoGrid My tiling had a fixed resolution that you specify up-front; I didn't really consider how to make my grid hierarchical.
- adrianratnapala 9y agoOf course a squareish grid can also be used to approximate a disc or ring. The approximation is not as pretty, but I don't see how it makes much difference for a query system.
- jacobolus 9y agoA triangular grid (or if you like, a grid of hexagonal pixels) is more efficient and closer to isotropic than a square grid. Circles pack more closely in a hexagonal arrangement than a square one.
- scdoshi 9y agoS2, linked from the README[1], does the same hierarchical subdivisions in squares, with each square having a string ID. Squares divide into sub-squares exactly, but hexagon's don't sub-divide into hexagon's neatly.[2] Can someone explain the advantages of hexagons over squares in this use case? [1]https://code.google.com/archive/p/s2-geometry-library/ https://code.google.com/archive/p/s2-geometry-library/ [2]https://www.illustrativemathematics.org/content-standards/tasks/1123 https://www.illustrativemathematics.org/content-standards/ta...
- dvanduzer 9y agoSee sibling post for links, but the short answer: you can use 12 pentagons, strategically interspersed. Like a (soccer) football. edit: Oops, that only explains the tiling. For explanations of how the hierarchy descends, Dr. Sahr produced some GIFs that give a little bit of an overview of how the resolutions overlay: http://webpages.sou.edu/~sahrk/dgg/images/topogif/topogif.html http://webpages.sou.edu/~sahrk/dgg/images/topogif/topogif.ht...
- scdoshi 9y agoThanks for that link. Also found this which goes into some more detailed comparison with rectangular grids: https://github.com/uber/h3/blob/master/docs/doxyfiles/usecases.md https://github.com/uber/h3/blob/master/docs/doxyfiles/usecas...
- jacobolus 9y agoGosper island shapes do subdivide into gosper island shapes, if you want something tricky: https://en.wikipedia.org/wiki/Gosper_curve#Properties https://en.wikipedia.org/wiki/Gosper_curve#Properties
- malandrew 9y agoBoundaries between all 6 neighbors are equal. With S2, four are on the sides and top are equal and the corner neighbors have only a single point as their boundary. This means you can better simulate dynamic systems where there is flow between cells.
- b0rsuk 9y agoI thought it was to make best use of all those hexagonal monitors ?
- jandrewrogers 9y agoDiscrete Global Grid Systems (DGGS), which is what this touches on, are a deceptively complex topic. You are optimizing for many performance dimensions, and some things that intuitively seem like they should be optimized for don't really matter, and other things people tend to ignore (like congruency) matter quite a bit. For example, "equal area" subdivision of the surface is not a particularly useful property. This seems like it is wrong on its face such that most people try to achieve it but you have to remember that equal area only matters if your data is uniformly and predictably distributed. Geospatial data models are neither in a pretty severe way as a rule, which means you'll have to deal with data load asymmetry regardless via some other mechanism. If you can ignore equal area because it is handled by some other mechanism, it opens up other possible surface decompositions that have much stronger properties in other ways. Compactness of representation and cost of computing relationships on the representation has a large impact on real-world index performance that is frequently ignored. The poorness of lat/lon grids in this regard is often significantly underestimated. A singularity-free 3D DGGS can have an indexing structure that is an order of magnitude smaller than a basic 2D lat/long grid for addressing, and the storage on disk of records encoded in these DGGS are also significantly smaller. This all adds up to a lot of performance. Hexagonal grids tend to work particularly well for visualization. However, they do have their own significant weaknesses e.g. it is typically not a good representation for join operations and they are relatively expensive to search at large scales relative to some other DGGS tessellation systems.
- espeed 9y agoHi Andrew - You went to school for chemistry and chemical engineering. I'm still experimenting with ideas for binary codes of succinct/implicit geometric representations for similarity graph embeddings of non-spatial property data like text and numbers. I keep bumping into the crystallography literature -- the traditional lattice structures and also quasicrystal / fibonacci chain representations. How much of your chemical engineering background have influenced your designs?
- jandrewrogers 9y agoAlmost no influence as related to spatial structure; I tend to view spatial structure as an information theoretic manifestation. On the other hand, chemical engineering had a big influence on how I reason about distributed systems. That discipline is essentially about the design of complex, continuous flow, coordination-free distributed computation systems that are robustly stable in an efficient equilibrium. It maps directly to computer science but has a concept of the problem space that I think is much more refined than what you commonly see in computer science though it is never expressed in computer science terms. But it makes sense, it is chemical engineering’s One Job.
- Guidii 9y agoSo there are a few reasons to favour hexagons (or triangles) over squares.... Squares don't pack as closely as hexes, meaning that you can get 18% more hexes into a space than squares for a given perimeter-size. Squares also degenerate badly over the surface of the sphere.... you can't keep a consistent size as you change latitude, and they turn into triangles when you reach the poles.
- timmaxw 9y agoGoogle S2 (a square-based alternative to Uber's H3) works by projecting the surface of the sphere onto the surface of a cube, then subdividing each face of the cube. So there's still some distortion around the edges and corners of the cube, but nowhere near as bad as a naive longitude/latitude strategy.
- cmaggard 9y agoSo MGRS[0] with hexagons? Pretty interesting. [0] https://en.wikipedia.org/wiki/Military_Grid_Reference_System https://en.wikipedia.org/wiki/Military_Grid_Reference_System
- acemarke 9y agoSeems more like Hierarchical Triangular Meshing with hexagons. I had to use that for a project a few years back. http://www.skyserver.org/htm/ http://www.skyserver.org/htm/ https://arxiv.org/ftp/cs/papers/0701/0701164.pdf https://arxiv.org/ftp/cs/papers/0701/0701164.pdf
- jacobolus 9y agoNo, the military grid is based on (a whole bunch of distinct skinny slices of) transverse Mercator projections, which don’t really line up properly at the seams, plus stereographic projections at the poles. It was largely designed for use with paper maps. Discrete global grid systems based on hexagons are an idea which differ in most respects from that, except for the part about hierarchical coordinates (which can also be done using any arbitrary other map projection).
- tejtm 9y agoSee Buckminster Fuller's Dymaxion map also [0](https://en.wikipedia.org/wiki/Dymaxion_map https://en.wikipedia.org/wiki/Dymaxion_map)
- snake_plissken 9y agoWhat's with the output of the hexagon's vertices? There technically isn't a 285th degree line of meridian, or are they saying, 285 degrees east from 0? In which case, why don't they just subtract 360 from all values greater than 180 (since the input is in decimal degrees)?
- deleted 9y ago[deleted]
- snake_plissken 9y agoLooks like it's just a rough edge per this very insightful comment: https://news.ycombinator.com/item?id=16136912 https://news.ycombinator.com/item?id=16136912
- copperx 9y agoHexagonal? Is this inspired in any way by Borges's Library of Babel?
- adrianratnapala 9y agoIs every face a hexagon? I thought to cover a sphere you had to throw in at least a few things that weren't hexagons. Euler and all that.
- rockinghigh 9y agoThere are pentagons: > The first H3 resolution (resolution 0) consists of 122 cells (110 hexagons and 12 icosahedron vertex-centered pentagons), referred to as the base cells. From: https://github.com/uber/h3/blob/9df3940473e2f0446cf38e22443c77c6b3935382/docs/doxyfiles/overview.md https://github.com/uber/h3/blob/9df3940473e2f0446cf38e22443c...
- jacobolus 9y agoIf you are willing to have some pairs of hexagons border each-other along two edges, you can squint and pretend to cover a sphere by hexagons alone. http://archive.bridgesmathart.org/2017/bridges2017-237.pdf http://archive.bridgesmathart.org/2017/bridges2017-237.pdf The way the discrete global grids people handle it (TFA is an implementation of that) is generally to stick 12 pentagonal pixels in their grid at the corners of an icosahedron.
- awshepard 9y agoCan anyone compare/contrast this with geohex.org? I've used geohex in a past life, just curious what, if anything, H3 might offer over it.
- dvanduzer 9y agoI have never heard of this library before, which is surprising, because I've been looking hard for such a hexagonal privacy-fencing system for a long time! I can't find anything that explains how the partitioning in geohex works, but the Uber system makes it clear that they are using Dr. Sahr's partitioning scheme: https://github.com/uber/h3/blob/master/docs/doxyfiles/h3indexing.md https://github.com/uber/h3/blob/master/docs/doxyfiles/h3inde...
- ISV_Damocles 9y agoI used to work at Uber and worked on H3. They're working on a blog post to explain some more, but if you clone the repo and build the doxygen docs, you'll get more explanation. 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 "checkerboard" neighbors that squares have. This lets you do some interesting analysis on data gathered with hexagons. 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. 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 "types" of hexagons (urban, suburban, etc) and then make predictions about cities you haven't even set up shop in, yet, based on similar cities. Hexagons are also the most efficient way to pack spheres, and can best approximate a circular radius with a discrete grid, so they'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. 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. 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're interested in. This C library wasn't meant to be used directly by most developers and that'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't wait until the bindings come out, too, probably with the blog post. :) [1]: https://en.wikipedia.org/wiki/Gosper_curve https://en.wikipedia.org/wiki/Gosper_curve
- 9y ago
- espeed 9y agoAlso see NASA JPL's HEALPix v3... "A multi-resolution HEALPix data structure for spherically mapped point data" (2017) http://www.heliyon.com/article/e00332 http://www.heliyon.com/article/e00332
- Guidii 9y agoOGC has a spec for Discrete Global Grids at http://docs.opengeospatial.org/as/15-104r5/15-104r5.html http://docs.opengeospatial.org/as/15-104r5/15-104r5.html It has a good overview of the implementation details, and pictures!