S2 cells covering a region
The cells that cover a latitude and longitude rectangle, a circle around a point, or a polygon with holes, within a level range and a cell budget.
A published result changed on 2026-09-24: S2 coverings of rectangles and circles (version 2.0.0) now come from a port of S2's own RegionCoverer, so they are the same cells S2 itself returns… Changelog
That region takes 8 S2 cells, from level 12 to 12.
| Cell | Level | Latitude | Longitude |
|---|---|---|---|
| 8834f15 | 12 | 40.4340198 deg | -79.9975916 deg |
| 8834f17 | 12 | 40.4320698 deg | -79.9752212 deg |
| 8834f19 | 12 | 40.4301150 deg | -79.9528451 deg |
| 8834f23 | 12 | 40.4502895 deg | -79.9528451 deg |
| 8834f3d | 12 | 40.4522446 deg | -79.9752212 deg |
| 8834f3f | 12 | 40.4541947 deg | -79.9975916 deg |
| 8834f41 | 12 | 40.4561400 deg | -80.0199562 deg |
| 8834f6b | 12 | 40.4359648 deg | -80.0199562 deg |
- Covered area
- Finest level
- Coarsest level
Provenance
- Computed by
- indexing.s2.covering 2.0.0, core 0.1.0
- Model
- Refinement from the six faces: the coarsest candidate that meets the region is split into its four children, keeping any cell the region contains whole, until the budget is reached; a cell that only partly overlaps is kept, so the covering contains the region. A polygon's edges are great circles, as in S2; a cell meets it when its center or a corner is inside (by the winding of the polygon's edges seen from there), an edge of the polygon crosses or touches one of the cell's, or a corner of the polygon lies in the cell, and it is whole inside when its four corners are inside and none of that boundary reaches it
- Accuracy
- The covering always contains the region. It is not the smallest such set: S2's own coverer uses a priority order that can find a tighter cover for the same budget, so treat the cells as a superset rather than a canonical answer.
- Notes
- None
- Cites
- Google, S2 Geometry
Something look off?
How we got thisFormula, worked example, sources, and proof
Model: Refinement from the six faces: the coarsest candidate that meets the region is split into its four children, keeping any cell the region contains whole, until the budget is reached; a cell that only partly overlaps is kept, so the covering contains the region. A polygon's edges are great circles, as in S2; a cell meets it when its center or a corner is inside (by the winding of the polygon's edges seen from there), an edge of the polygon crosses or touches one of the cell's, or a corner of the polygon lies in the cell, and it is whole inside when its four corners are inside and none of that boundary reaches it
Accuracy: The covering always contains the region. It is not the smallest such set: S2's own coverer uses a priority order that can find a tighter cover for the same budget, so treat the cells as a superset rather than a canonical answer.
When to use this: Use this to turn an area into index keys: the cells of a covering are what you query a cell-indexed store with, then filter the results by the true geometry. The budget and the level range are the two knobs — more cells or finer levels mean a tighter cover and a larger key set.
Limitations: A covering is a superset: every cell overlaps the region but the cells together cover more ground than it, which is why a covering query still needs a second filter. A polygon's edges are great circles, as S2 draws them, not lines of constant bearing and not geodesics on the ellipsoid; for edges of more than a few hundred kilometers, add corners if the boundary should follow something else. A polygon must be smaller than a hemisphere. The cells are a valid covering rather than S2's own choice, so a set from another library may differ while covering the same ground. The cell budget is not a hard cap: the lowest level wins over it, so a region that needs more cells than the budget just to reach that level gets them, with a warning saying so -- a smaller set would leave part of the region out. Past four times the budget the request is refused instead.
Worked example: A small box near Pittsburgh in at most 8 cells. Source: add-spatial-indexing-and-raster hierarchical-cells scenario: at most 8 cells, all between levels 10 and 16, together covering the region. It is golden test vector v024, and every build checks the tool still gives its answer within its tolerance.
You enter
- East edge
- -79.96 deg
- Cell budget
- 8
- Highest level
- 16
- Lowest level
- 10
- North edge
- 40.46 deg
- South edge
- 40.43 deg
- West edge
- -80.01 deg
You get
- Cells
- 8
- Covered area
- 33.975 km²
- Finest level
- 12
- Coarsest level
- 12
Review: Not yet independently reviewed by a GIS professional.
Last verified: 2026-09-22, when a maintainer last confirmed this tool's sources at the issuer. See the sources ledger.
Status: version 2.0.0, core 0.1.0. See this tool in the verification report.
Changes
- 2026-09-24, result change: S2 coverings of rectangles and circles (version 2.0.0) now come from a port of S2's own RegionCoverer, so they are the same cells S2 itself returns and can be exchanged with other S2 systems. Before, this tool refined from the six cube faces with its own rule, which gave valid but different coverings, often with more cells than needed. The new coverings match s2sphere cell for cell on 400 random regions. Polygon coverings are unchanged. The superseded vectors pinned the old coverings. Changelog
Checked against: 23 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.
Constants this tool assumes
Values you do not enter, and where each comes from.
- Mean Earth radius, GRS 80's R1 (6371008.7714 m) to 0.1 m
6371008.8 m— Geodetic Reference System 1980
Sources
- S2 Geometry, Google, S2 Geometry library. Cell ids, the quadratic projection, the Hilbert curve, tokens, and cell hierarchy.
Terms
- S2: S2 Geometry
- A way of indexing the sphere: the Earth is projected onto a cube, each face is traced by a Hilbert curve, and a cell is a position along that curve at a level from 0 to 30. Source: S2 Geometry
S2 — S2 Geometry
A way of indexing the sphere: the Earth is projected onto a cube, each face is traced by a Hilbert curve, and a cell is a position along that curve at a level from 0 to 30.
Source: S2 Geometry