Skip to main content
Returns the S2 cell ID, which uniquely identifies the region on Earth that fully contains, or covers, a single Point GEOGRAPHY object. ST_S2CELLIDFROMPOINT exclusively supports single Point GEOGRAPHY objects, and returns NULL for all other values including MultiPoint, LineString, Polygon, and an empty GEOGRAPHY object.

Syntax

Parameters

Return Type

ST_S2CELLIDFROMPOINT returns a value of type BIGINT, which may include negative values.

Example

The following code example constructs a dataset containing three GEOGRAPHY objects: a valid Point, an empty Point, and a LineString. The code example computes their S2 cell IDs at cell levels 30 (finest resolution, default) and 10, returning results only for the valid Point. The function returns NULL for the second input because it is empty and contains no geographic data, and for the third input because LineString is not a supported GEOGRAPHY type.

Rows: 3Execution time: 5.60ms