geo.shapeData() function

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

The geo.shapeData() function renames existing latitude and longitude fields to lat and lon and adds an s2_cell_id tag. Use geo.shapeData() to ensure geo-temporal data meets the requirements of the Geo package:

  1. Rename existing latitude and longitude fields to lat and lon.
  2. Pivot data into row-wise sets based on _time.
  3. Generate s2_cell_id tags using lat and lon values and a specified S2 cell level.

*Function type: Transformation*

  1. import "experimental/geo"
  2. geo.shapeData(
  3. latField: "latitude",
  4. lonField: "longitude",
  5. level: 10
  6. )

Parameters

latField

Name of the existing field that contains the latitude value in decimal degrees (WGS 84). Field is renamed to lat.

*Data type: String*

lonField

Name of the existing field that contains the longitude value in decimal degrees (WGS 84). Field is renamed to lon.

*Data type: String*

level

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

*Data type: Integer*

Examples

Shape data to meet the requirements of the Geo package
  1. import "experimental/geo"
  2. from(bucket: "example-bucket")
  3. |> range(start: -1h)
  4. |> filter(fn: (r) => r._measurement == "example-measurement")
  5. |> geo.shapeData(
  6. latField: "latitude",
  7. lonField: "longitude",
  8. level: 10
  9. )

geo.shapeData input and output

Given the following input:

_time_field_value
0001latitude30.0
0002latitude30.5
0003latitude30.7
0004latitude31.1
• • •• • •• • •
0001longitude20.0
0002longitude19.8
0003longitude19.2
0004longitude19.5

The following function would output:

  1. |> geo.shapeData(
  2. latField: "latitude",
  3. lonField: "longitude",
  4. level: 5
  5. )
_timelatlons2_cell_id
000130.020.0138c
000230.519.81384
000330.719.2139c
000431.119.5139c

Related articles

functions geo