S2
S2 cells: a point to a cell id or token at any level, what a cell covers, and the cells across its edges.
S2 projects a cube onto the sphere and splits each face into four children per level, from level 0 down to level 30, where cells are about 1 cm across. These tools turn a point into a cell id or token, describe what a cell covers, find its edge neighbors across cube faces, and cover a box or circle with cells. Developers use S2 for 64-bit spatial keys and region coverings. Start with the point-to-cell tool. Pitfall: a token and a 64-bit id are two spellings of the same cell, so compare like with like.
I want to turn a point into an S2 cell, or read a token
- S2 cell for a point
The S2 cell containing a latitude and longitude at a level from 0 to 30, with its token, its 64-bit id, the face it sits on, and its area.
- S2 cell details
Everything about an S2 cell: its center, its four corners, the face and level, its exact area against the average for that level, and its parent and children.
I want to find the cells around one, including across a cube face
- S2 edge neighbours
The four cells across an S2 cell's edges, at the same level, wrapping onto the next cube face where the cell lies on a face edge.
I want to cover a box or a circle with S2 cells
- S2 cells covering a region
The S2 cells that cover a latitude and longitude rectangle, or a circle around a point, within a level range and a cell budget.