Documentation

geo.s2CellIDToken() function

Flux 0.63.0+

The geo.s2CellIDToken() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The geo.s2CellIDToken() function returns an S2 cell ID token.

import "experimental/geo"

geo.s2CellIDToken(
  point: {lat: 37.7858229, lon: -122.4058124},
  level: 10
)

Parameters

point

Longitude and latitude in decimal degrees (WGS 84) to use when generating the S2 cell ID token. Record must contain lat and lon properties.

token

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

point and token are mutually exclusive.

level

S2 cell level to use when generating the S2 cell ID token.

Examples

Use latitude and longitude values to generate S2 cell ID tokens
import "experimental/geo"

from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "example-measurement")
  |> map(fn: (r) => ({
    r with
    s2_cell_id: geo.s2CellIDToken(
      point: {lat: r.lat, lon: r.lon},
      level: 10
    )})
  )
Update S2 cell ID token level
import "experimental/geo"

from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "example-measurement")
  |> map(fn: (r) => ({
    r with
    s2_cell_id: geo.s2CellIDToken(
      token: r.s2_cell_id,
      level: 10
    )})
  )

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.