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
| Parameter | Description | Supported input types |
|---|---|---|
<geo> | A single valid GEOGRAPHY Point for which ST_S2CELLIDFROMPOINT calculates and returns the S2 cell that covers it. | GEOGRAPHY |
<cell_level> | The resolution of the S2 cell to return. Valid levels range from 0, the coarsest level, to 30, the finest level. The default level is 30 if unspecified. | BIGINT |
Return Type
ST_S2CELLIDFROMPOINT returns a value of type BIGINT, which may include negative values.
Example
The following code example constructs a dataset containing threeGEOGRAPHY objects: a valid Point, an empty Point, and a LineString. The code example computes their S2 cell IDs at cell levels 30 and 10, returning results only for the valid Point:
| id (INTEGER) | cell30 (BIGINT) | cell10 (BIGINT) |
|---|---|---|
| 1 | 6093613931972369317 | 6093613287902019584 |
| 2 | NULL | NULL |
| 3 | NULL | NULL |
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.