geoprimsField-grade geospatial math

S2 cells covering a region

The cells that cover a latitude and longitude rectangle, or a circle around a point, within a level range and a cell budget.

6

That region takes 6 S2 cells, from level 10 to 11.

Covering
CellLevelLatitudeLongitude
8834f141140.4229554 deg-79.9864071 deg
8834f1c1140.4190459 deg-79.9416549 deg
8834f241140.4593947 deg-79.9416549 deg
8834f3c1140.4633051 deg-79.9864071 deg
8834f51040.4892989 deg-80.0534923 deg
8834f71040.4085968 deg-80.0534923 deg
Covered area
Finest level
Coarsest level
Provenance
Computed by
indexing.s2.covering 1.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
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?

Your values

Showing an example. Change anything.
More options 4
Run many at once from a CSV

Loading…

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

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. This covers a rectangle or a circle; polygons are not covered yet. 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 v001, 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
6
Covered area
203.756 km²
Finest level
11
Coarsest level
10

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 1.0.0, core 0.1.0. See this tool in the verification report.

Checked against: 22 golden test vectors (download the test vectors, each with its source and tolerance). See how results are checked and every source.

Sources

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