I would like to get the h3 cell index of every cell that is at least partially within a bounding box. I have been using h3.polygonToCells()
but it appears that h3.polygonToCells()
only returns cells that are mostly within the bounding box (polygon).
This how the coverage looks over central London, with resolution 3:
const coords = [
[51.55, -0.01],
[51.45, -0.01],
[51.45, -0.16],
[51.55, -0.16],
];
let RESOLUTION_LEVEL = 3;
const cells = h3.polygonToCells(coords, RESOLUTION_LEVEL, false);
console.log("cells", cells); // returns an array of 0 items
And now the same area, with resolution 7:
RESOLUTION_LEVEL = 7;
const cells = h3.polygonToCells(coords, RESOLUTION_LEVEL, false);
console.log("cells", cells); // returns an array of 26 items
How do I get all the H3 cell indexes for the whole bounding box?
You probably want to use the h3shape_to_cells_experimental function instead, with the overlap
flag.
https://h3geo.org/docs/api/regions#polygontocellsexperimental