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).
Asked
Active
Viewed 1,054 times
1 Answers
0
Refining the H3 polyfill
output is generally a two-step process:
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 takingkRing(cell, 1)
for every cell and adding the output to a new set (e.g. in JS:Set(cells.flatMap(cell => kRing(cell, 1)))
).Filter the set of cells by your chosen criteria. This might require an external spatial library with functions like
touches
orintersects
, 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)))

nrabinowitz
- 55,314
- 10
- 149
- 165