---
title: geo.s2CellIDToken() function
description: geo.s2CellIDToken() returns and S2 cell ID token for given cell or point at a specified S2 cell level.
url: https://docs.influxdata.com/flux/v0/stdlib/experimental/geo/s2cellidtoken/
estimated_tokens: 2287
product: Flux
version: v0
---

# geo.s2CellIDToken() function

-   Flux 0.64.0+
-   View InfluxDB support

`geo.s2CellIDToken()` is experimental and [subject to change at any time](/flux/v0/stdlib/experimental/#experimental-packages-are-subject-to-change).

`geo.s2CellIDToken()` returns and S2 cell ID token for given cell or point at a specified S2 cell level.

##### Function type signature

```js
(level: int, ?point: {lon: float, lat: float}, ?token: string) => string
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### token

S2 cell ID token to update.

Useful for changing the S2 cell level of an existing S2 cell ID token.

### point

Record with `lat` and `lon` properties that specify the latitude and longitude in decimal degrees (WGS 84) of a point.

### level

(Required) S2 cell level to use when generating the S2 cell ID token.

## Examples

-   [Use latitude and longitude values to generate S2 cell ID tokens](#use-latitude-and-longitude-values-to-generate-s2-cell-id-tokens)
-   [Update S2 cell ID token level](#update-s2-cell-id-token-level)

### Use latitude and longitude values to generate S2 cell ID tokens

```js
import "experimental/geo"

data
    |> map(
        fn: (r) =>
            ({r with s2_cell_id: geo.s2CellIDToken(point: {lat: r.lat, lon: r.lon}, level: 10)}),
    )
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| _time | *id | lon | lat |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | a213b | 39.7515 | 14.01433 |
| 2021-01-02T01:00:00Z | a213b | 38.3527 | 13.9228 |
| 2021-01-03T02:00:00Z | a213b | 36.9978 | 15.08433 |

| _time | *id | lon | lat |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | b546c | 24.0069 | -14.5464 |
| 2021-01-02T01:00:00Z | b546c | 25.1304 | -13.3338 |
| 2021-01-03T02:00:00Z | b546c | 26.7899 | -12.0433 |

#### Output data

| _time | *id | lat | lon | s2_cell_id |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | a213b | 14.01433 | 39.7515 | 166b59 |
| 2021-01-02T01:00:00Z | a213b | 13.9228 | 38.3527 | 16696d |
| 2021-01-03T02:00:00Z | a213b | 15.08433 | 36.9978 | 166599 |

| _time | *id | lat | lon | s2_cell_id |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | b546c | -14.5464 | 24.0069 | 1960d7 |
| 2021-01-02T01:00:00Z | b546c | -13.3338 | 25.1304 | 1965c7 |
| 2021-01-03T02:00:00Z | b546c | -12.0433 | 26.7899 | 1971dd |

### Update S2 cell ID token level

```js
import "experimental/geo"

data
    |> map(fn: (r) => ({r with s2_cell_id: geo.s2CellIDToken(token: r.s2_cell_id, level: 5)}))
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| _time | *id | s2_cell_id |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | a213b | 166b59 |
| 2021-01-02T01:00:00Z | a213b | 16696d |
| 2021-01-03T02:00:00Z | a213b | 166599 |

| _time | *id | s2_cell_id |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | b546c | 1960d7 |
| 2021-01-02T01:00:00Z | b546c | 1965c7 |
| 2021-01-03T02:00:00Z | b546c | 1971dd |

#### Output data

| _time | *id | s2_cell_id |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | a213b | 166c |
| 2021-01-02T01:00:00Z | a213b | 166c |
| 2021-01-03T02:00:00Z | a213b | 1664 |

| _time | *id | s2_cell_id |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | b546c | 1964 |
| 2021-01-02T01:00:00Z | b546c | 1964 |
| 2021-01-03T02:00:00Z | b546c | 1974 |

#### Related

-   [Work with geo-temporal data](/influxdb/v2/query-data/flux/geo/)

[geotemporal](/flux/v0/tags/geotemporal/)
