Error when using experimental/geo package

Hello,
I just started playing around with geolocation data :slight_smile:
I have coordinates and I want to group points into areas using geo.groupByArea() function but I get the following error:

error calling function "groupByArea" @14:8-14:55: error calling function "_detectLevel" @geo.flux|195:12-195:26: error calling function "tableFind" @geo.flux|82:10-82:55: no table found

Here a minimal example to reproduce the error:

import "array"
import "experimental/geo"

array.from(rows: [
    {lat: 53.4808, lon: 2.2426},
    {lat: 51.5074, lon: 0.1278}
])
    |> map(fn: (r) => ({ r with s2_cell_id: 
        geo.s2CellIDToken(
            point: {lat: r.lat, lon: r.lon},
            level: 10
        )
    }))
    |> geo.groupByArea(newColumn: "geoArea", level: 5)

I tried a few workarounds but Iā€™m still unable to make it work.
Thanks for the help

@eloparco What version of InfluxDB / Flux are you using?

Sorry I forgot, Flux version v0.104.0.

Looking at the _detectLevel() function source code in the Geo package, it requires the s2_cell_id column to be in the group key (data needs to be grouped by s2_cell_id). Try the following:

import "array"
import "experimental/geo"

array.from(rows: [
    {lat: 53.4808, lon: 2.2426},
    {lat: 51.5074, lon: 0.1278}
])
    |> map(fn: (r) => ({ r with s2_cell_id: 
        geo.s2CellIDToken(
            point: {lat: r.lat, lon: r.lon},
            level: 10
        )
    }))
    |> group(columns: ["s2_cell_id"])
    |> geo.groupByArea(newColumn: "geoArea", level: 5)

Awesome, that was the solution. Thanks!