As mentioned in the accepted answer on how to identify hexagons which overlap, i am confused as to how we can identify fully contained, partially contained or contiguous cells of a polygon (check if it intersects the polygon).

1

There are 1 answers

0
nrabinowitz On

Refining the H3 polyfill output is generally a two-step process:

  1. If needed, buffer the polyfill output to include cells that might match your chosen criteria but do not have a center inside the polygon. This is necessary for partially contained or contiguous cases. The buffering operation can be performed by taking kRing(cell, 1) for every cell and adding the output to a new set (e.g. in JS: Set(cells.flatMap(cell => kRing(cell, 1)))).

  2. Filter the set of cells by your chosen criteria. This might require an external spatial library with functions like touches or intersects, or you might need to implement these yourself. Generally you would take the boundary of each cell and compare to your polygon, e.g.

cells.filter(cell => intersects(h3ToGeoBoundary(cell), myPolygon)))