> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for ST_S2CELLIDFROMPOINT function

# ST_S2CELLIDFROMPOINT

Returns the [S2 cell ID](http://s2geometry.io/devguide/s2cell_hierarchy), 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

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
ST_S2CELLIDFROMPOINT(<geo> [, <cell_level> ])
```

## 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 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.

<div className="query-window">
  ```
  WITH data AS (
    SELECT 1 AS id, ST_GEOGFROMTEXT('POINT(-122 47)') AS geo
    UNION ALL
    SELECT 2 AS id, ST_GEOGFROMTEXT('POINT EMPTY') AS geo
    UNION ALL
    SELECT 3 AS id, ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)') AS geo
  )
  SELECT id,
         ST_S2CELLIDFROMPOINT(geo) cell30,
         ST_S2CELLIDFROMPOINT(geo, 10) cell10
  FROM data;
  ```

  | id <span>int</span> | cell30 <span>long null</span> | cell10 <span>long null</span> |
  | :------------------ | :---------------------------- | :---------------------------- |
  | 1                   | 6093613931972369317           | 6093613287902019584           |
  | 2                   | NULL                          | NULL                          |
  | 3                   | NULL                          | NULL                          |

  <p><span>Rows: 3</span><span>Execution time: 5.60ms</span></p>
</div>
