---
title: Group geo-temporal data
description: Use the geo.groupByArea() to group geo-temporal data by area and geo.asTracks() to group data into tracks or routes.
url: https://docs.influxdata.com/influxdb/v2/query-data/flux/geo/group-geo-data/
estimated_tokens: 741
product: InfluxDB OSS v2
version: v2
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb/v2/query-data/flux/geo/group-geo-data/
date: '2025-04-02T15:54:32-06:00'
lastmod: '2025-04-02T15:54:32-06:00'
---

This page documents an earlier version of InfluxDB OSS.[InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

#### API token hashing is enabled by default in InfluxDB OSS 2.9.0

Stronger token security: tokens are stored as hashes on disk, so a
copy of the database file doesn’t expose usable tokens. Existing
tokens are hashed on first startup and the original strings can’t
be recovered afterward — **capture any plaintext tokens you still
need before you upgrade**.

For more information, see [Token hashing](/influxdb/v2/admin/tokens/#token-hashing).

Use the `geo.groupByArea()` to group geo-temporal data by area and `geo.asTracks()`to group data into tracks or routes.

* [Group data by area](#group-data-by-area)
* [Group data into tracks or routes](#group-data-by-track-or-route)

> [!Note]
> For example results, use the [bird migration sample data](/influxdb/v2/reference/sample-data/#bird-migration-sample-data)to populate the `sampleGeoData` variable in the queries below.

### Group data by area

Use the [`geo.groupByArea()` function](/flux/v0/stdlib/experimental/geo/groupbyarea/)to group geo-temporal data points by geographic area.
Areas are determined by [S2 grid cells](https://s2geometry.io/devguide/s2cell_hierarchy.html#s2cellid-numbering)

* Specify a new column to store the unique area identifier for each point with the `newColumn` parameter.
* Specify the [S2 cell level](https://s2geometry.io/resources/s2cell_statistics)to use when calculating geographic areas with the `level` parameter.

The following example uses the [sample bird migration data](/influxdb/v2/query-data/flux/geo/#sample-data)to query data points within 200km of Cairo, Egypt and group them by geographic area:

```js
import "experimental/geo"

sampleGeoData
    |> geo.filterRows(region: {lat: 30.04, lon: 31.23, radius: 200.0})
    |> geo.groupByArea(newColumn: "geoArea", level: 5)
```

### Group data by track or route

Use [`geo.asTracks()` function](/flux/v0/stdlib/experimental/geo/astracks/)to group data points into tracks or routes and order them by time or other columns.
Data must contain a unique identifier for each track. For example: `id` or `tid`.

* Specify columns that uniquely identify each track or route with the `groupBy` parameter.
* Specify which columns to sort by with the `sortBy` parameter. Default is `["_time"]`.

The following example uses the [sample bird migration data](/influxdb/v2/query-data/flux/geo/#sample-data)to query data points within 200km of Cairo, Egypt and group them into routes unique
to each bird:

```js
import "experimental/geo"

sampleGeoData
    |> geo.filterRows(region: {lat: 30.04, lon: 31.23, radius: 200.0})
    |> geo.asTracks(groupBy: ["id"], orderBy: ["_time"])
```

#### Related

* [geo package](/flux/v0/stdlib/experimental/geo/)
* [geo.groupByArea() function](/flux/v0/stdlib/experimental/geo/groupbyarea/)
* [geo.asTracks() function](/flux/v0/stdlib/experimental/geo/astracks/)
