Closed gigatexal closed 2 years ago
This can be done using the cellToParent
(h3ToParent
in v3) function. This is a very efficient function as it only does bitwise operations on the index. Since hexagons don't cleanly subdivide, there will be areas where the original point would index into a different cell at the coarser resolution.
This can be done using the
cellToParent
(h3ToParent
in v3) function. This is a very efficient function as it only does bitwise operations on the index. Since hexagons don't cleanly subdivide, there will be areas where the original point would index into a different cell at the coarser resolution.
To expand on this, @nrabinowitz has a very nice interactive diagram of the hierarchical relationship that you can play with. While these are different resolutions, the delta between them is the same so the abstract geometry would look nearly identical to this:
The vast majority of the cells overlap, but a few, due to the partial non-containment visible on the first parent-to-child level, as shown below, causes containment "drift" as you go to smaller and smaller resolutions, in a fractal-like pattern.
A more computationally expensive operation can be done to establish containment by hexagon centerpoint. Simply calling cellToLatLng
(aka h3ToGeo
in v3) to get the center coordinates of the res 11 cells and then feeding that into latLngToCell
(geoToH3
in v3) at resolution 8. This will have the data assigned according to the geographic containment rather than the hierarchical containment, but is multiple orders of magnitude slower.
Wonderful answers. Thank you both!
Hi folks,
Unsure if this is even the right place to ask or if this even makes sense -- it seems like it might.
We've a data source that is sending level 11 indexes and we'd like to convert them to level 8 (larger areas from the "higher resolution" level 11 index). But I am unsure how to do this using the functions provided in the API.
-Alex