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).
Given H3 cells from polyfill, how to identify cells which are fully contained, partially contained or contiguous with the polygon?
1.2k views Asked by iamthecoderman At
1
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.