0

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

picture showing map with H3 resolution 7 - no cells returned

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

picture showing map with H3 resolution 3 - many cells returned, all with a majority of the cell inside the bounding box

How do I get all the H3 cell indexes for the whole bounding box?

jam3
  • 129
  • 5
  • You can use the approach outlined in [this answer](https://stackoverflow.com/a/72967263/1785661). It's written in Python, bu the exact same approach will work in javascript, too. – Dahn Mar 27 '23 at 23:08

0 Answers0