geo.groupByArea() function

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

The geo.groupByArea() function groups rows by geographic area. Area sizes are determined by the specified level. Each geographic area is assigned a unique identifier which is stored in the newColumn. Results are grouped by newColumn.

*Function type: Transformation*

  1. import "experimental/geo"
  2. geo.groupByArea(
  3. newColumn: "geoArea",
  4. level: 3,
  5. s2cellIDLevel: -1
  6. )

Parameters

newColumn

Name of the new column that stores the unique identifier for a geographic area.

*Data type: String*

level

S2 Cell level used to determine the size of each geographic area.

*Data type: Integer*

s2cellIDLevel

S2 Cell level used in s2_cell_id tag. Default is -1.

*Data type: Integer*

When set to -1, geo.groupByArea() attempts to automatically detect the S2 Cell ID level.

Examples

  1. import "experimental/geo"
  2. region = {
  3. minLat: 40.51757813,
  4. maxLat: 40.86914063,
  5. minLon: -73.65234375,
  6. maxLon: -72.94921875
  7. }
  8. from(bucket: "example-bucket")
  9. |> range(start: -1h)
  10. |> filter(fn: (r) => r._measurement == "example-measurement")
  11. |> geo.gridFilter(region: region)
  12. |> geo.toRows()
  13. |> geo.groupByArea(newColumn: "geoArea", level: 3)

Related articles

functions geo