geo.strictFilter() function
The geo.strictFilter()
function is experimental and subject to change at any time.
By using this function, you accept the risks of experimental functions.
The geo.strictFilter()
function filters data by latitude and longitude in a specified region.
This filter is more strict than geo.gridFilter()
,
but for the best performance, use geo.strictFilter()
after geo.gridFilter()
.
See Strict and non-strict filtering below.
import "experimental/geo"
geo.strictFilter(
region: {lat: 40.69335938, lon: -73.30078125, radius: 20.0},
)
geo.strictFilter()
requires lat
and lon
columns in each row.
Use geo.toRows()
to pivot lat
and lon
fields into each row before using geo.strictFilter()
.
Strict and non-strict filtering
In most cases, the specified geographic region does not perfectly align with S2 grid cells.
- Strict filtering returns only points inside the specified region.
- Non-strict filtering returns points that may be outside of the specified region but inside S2 grid cells partially covered by the region.
S2 grid cell
Filter region
Returned point
Strict filtering
Non-strict filtering
Parameters
region
The region containing the desired data points. Specify record properties for the shape. See Region definitions.
tables
Input data.
Default is piped-forward data (<-
).
Examples
Filter data in a box-shaped region
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.toRows()
|> geo.strictFilter(region: region)
Filter data in a circular region
import "experimental/geo"
region = {lat: 40.69335938, lon: -73.30078125, radius: 20.0}
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "example-measurement")
|> geo.toRows()
|> geo.strictFilter(region: region)
Filter data in a custom polygon region
import "experimental/geo"
region = {
points: [{lat: 40.671659, lon: -73.936631}, {lat: 40.706543, lon: -73.749177}, {lat: 40.791333, lon: -73.880327}],
}
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "example-measurement")
|> geo.toRows()
|> geo.strictFilter(region: region)
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.