Skip to main content
Cover the geometry with Google S2 Cells, return the corresponding cell IDs with the given level. The level indicates the size of cells. With a bigger level, the cells will be smaller, the coverage will be more accurate, but the result size will be exponentially increasing.

Signatures

ST_S2CellIDs(geom: Geometry, level: Integer)

Parameters

geom
Geometry
required
The input geometry.
level
Integer
required
The level value.

Return type

An integer value.

Example

SELECT ST_S2CellIDs(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'), 6)
[1159395429071192064, 1159958379024613376, 1160521328978034688, 1161084278931456000, 1170091478186196992, 1170654428139618304]
ST_S2CellIDs