S2 cell for a point
The 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.
That is S2 cell 8834f3dec at level 15.
- Cell id
- Level
- Face
- Center latitude
- Center longitude
- Cell area
Provenance
- Computed by
- indexing.s2.lat-lng-to-cell 1.0.0, core 0.1.0
- Model
- The S2 quadratic projection onto a cube face, the Hilbert curve across that face, and the cell id's face, position, and level bits
- Accuracy
- Matches s2sphere, an independent implementation of the same algorithms, on 400 cases across the sphere at every kind of level: identical tokens and neighbours, and geometry within 10 nanometers.
- Notes
- None
- Cites
- Google, S2 Geometry
Something look off?
How we got thisFormula, worked example, sources, and proof
Model: The S2 quadratic projection onto a cube face, the Hilbert curve across that face, and the cell id's face, position, and level bits
Accuracy: Matches s2sphere, an independent implementation of the same algorithms, on 400 cases across the sphere at every kind of level: identical tokens and neighbours, and geometry within 10 nanometers.
When to use this: Use this to key data by S2, which is what BigQuery GIS, MongoDB, and a number of mapping pipelines index with: a point becomes a cell at the level you choose, and cells at a level can be joined, counted, or compared. The token is the short form that travels in APIs; the decimal id is what most databases store.
Limitations: A cell is an area and the point is somewhere inside it, so a join at too coarse a level hides structure and one at too fine a level scatters it. S2 cells are not equal-area: the quadratic projection holds the variation to about 2.1 to 1 across a face, which is enough to matter when counting per cell. Levels run 0 to 30, and a level 30 cell is about a centimeter, which is finer than most positions are known to.
Worked example: Pittsburgh at level 15. Source: add-spatial-indexing-and-raster hierarchical-cells scenario: the token is 8834f3dec. It is golden test vector v001, and every build checks the tool still gives its answer within its tolerance.
You enter
- Latitude
- 40.446111 deg
- Level
- 15
- Longitude
- -79.982222 deg
You get
- S2 cell
- 8834f3dec
- Cell id
- 9814737625976668160
- Level
- 15
- Face
- 4
- Center latitude
- 40.4465506°
- Center longitude
- -79.9822126°
- Cell area
- 66,352.65 m²
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.
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