Work with geo-temporal data

Use the Flux Geo package to filter geo-temporal data and group by geographic location or track.

The Geo package is experimental and subject to change at any time. By using it, you agree to the risks of experimental functions.

To work with geo-temporal data:

  1. Import the experimental/geo package.

    1. import "experimental/geo"
  2. Load geo-temporal data. See below for sample geo-temporal data.

  3. Do one or more of the following:

Shape data to work with the Geo package

Functions in the Flux Geo package require lat and lon fields and an s2_cell_id tag. Rename latitude and longitude fields and generate S2 cell ID tokens.

  1. import "experimental/geo"
  2. sampleGeoData
  3. |> geo.shapeData(latField: "latitude", lonField: "longitude", level: 10)

Filter geo-temporal data by region

Use the geo.filterRows function to filter geo-temporal data by box-shaped, circular, or polygonal geographic regions.

  1. import "experimental/geo"
  2. sampleGeoData
  3. |> geo.filterRows(region: {lat: 30.04, lon: 31.23, radius: 200.0}, strict: true)

Group geo-temporal data

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

  1. import "experimental/geo"
  2. sampleGeoData
  3. |> geo.groupByArea(newColumn: "geoArea", level: 5)
  4. |> geo.asTracks(groupBy: ["id"],sortBy: ["_time"])

Sample data

Many of the examples in this section use a sampleGeoData variable that represents a sample set of geo-temporal data. The Bird Migration Sample Data provides sample geo-temporal data that meets the requirements of the Flux Geo package.

Load bird migration sample data

Use the sample.data() function to load the sample bird migration data:

  1. import "influxdata/influxdb/sample"
  2. sampleGeoData = sample.data(set: "birdMigration")

sample.data() downloads sample data each time you execute the query (~1.3 MB). If bandwidth is a concern, use the to() function to write the data to a bucket, and then query the bucket with from().