geo.s2CellIDToken() function

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.

*Function type: Transformation*

  1. import "experimental/geo"
  2. geo.s2CellIDToken(
  3. point: {lat: 37.7858229, lon: -122.4058124},
  4. level: 10
  5. )

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.

*Data type: Record*

token

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

*Data type: String*

point and token are mutually exclusive.

level

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

*Data type: Integer*

Examples

Use latitude and longitude values to generate S2 cell ID tokens
  1. import "experimental/geo"
  2. from(bucket: "example-bucket")
  3. |> range(start: -1h)
  4. |> filter(fn: (r) => r._measurement == "example-measurement")
  5. |> map(fn: (r) => ({
  6. r with
  7. s2_cell_id: geo.s2CellIDToken(
  8. point: {lat: r.lat, lon: r.lon},
  9. level: 10
  10. )})
  11. )
Update S2 cell ID token level
  1. import "experimental/geo"
  2. from(bucket: "example-bucket")
  3. |> range(start: -1h)
  4. |> filter(fn: (r) => r._measurement == "example-measurement")
  5. |> map(fn: (r) => ({
  6. r with
  7. s2_cell_id: geo.s2CellIDToken(
  8. token: r.s2_cell_id,
  9. level: 10
  10. )})
  11. )

Related articles

functions geo