Documentation

geo.gridFilter() function

geo.gridFilter() is experimental and subject to change at any time.

geo.gridFilter() filters data by a specified geographic region.

The function compares input data to a set of S2 cell ID tokens located in the specified region. Input data must include an s2_cell_id column that is part of the group key.

Note: S2 Grid cells may not perfectly align with the defined region, so results may include data with coordinates outside the region, but inside S2 grid cells partially covered by the region. Use geo.toRows() and geo.strictFilter() after geo.gridFilter() to precisely filter points.

Function type signature
(
    <-tables: stream[{B with s2_cell_id: string}],
    region: A,
    ?level: int,
    ?maxSize: int,
    ?minSize: int,
    ?s2cellIDLevel: int,
    ?units: {distance: string},
) => stream[{B with s2_cell_id: string}] where A: Record
For more information, see Function type signatures.

Parameters

region

(Required) Region containing the desired data points.

Specify record properties for the shape.

minSize

Minimum number of cells that cover the specified region. Default is 24.

maxSize

Maximum number of cells that cover the specified region. Default is -1 (unlimited).

level

S2 cell level of grid cells. Default is -1.

Note: level is mutually exclusive with minSize and maxSize and must be less than or equal to s2cellIDLevel.

s2cellIDLevel

S2 cell level used in the s2_cell_id tag. Default is -1 (detects S2 cell level from the S2 cell ID token).

units

Record that defines the unit of measurement for distance. Default is the geo.units option.

tables

Input data. Default is piped-forward data (<-).

Examples

Filter data to a specified region

import "experimental/geo"

data
    |> geo.gridFilter(region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0})

View example input and output


Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: