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

import "experimental/geo"

  newColumn: "geoArea",
  level: 3,
  s2cellIDLevel: -1



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

Data type: String


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

Data type: Integer


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.


import "experimental/geo"

region = {
  minLat: 40.51757813,
  maxLat: 40.86914063,
  minLon: -73.65234375,
  maxLon: -72.94921875

from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "example-measurement")
  |> geo.gridFilter(region: region)
  |> geo.toRows()
  |> geo.groupByArea(newColumn: "geoArea", level: 3)

Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: