I have data from a vehicle's route in InfluxDB with geotagging in the variables Latitude
and Longitude
. I would like to display the data as Markers in a Grafana Geomap panel.
My query for the data in Grafana looks as below:
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "1F4F8F26")
|> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] == "Longitude")
|> aggregateWindow(every: v.windowPeriod, fn: median)
|> yield(name: "median")
This query lets me plot the data as in the following picture:
In table form, the data looks as follows (note how I can switch between display Latitude and Longitude separately):
The problem is that when I try to use a Geomap panel, nothing is displayed as per below:
I have tried also with a restructuring of my data into a Time, Latitude, Longitude
format via below query:
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "1F4F8F26")
|> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] == "Longitude")
|> aggregateWindow(every: v.windowPeriod, fn: median)
|> yield(name: "median")
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
However, this still does not enable me to display the points as markers in Grafana. Any inputs are welcome.
I suggest to remove the aggregation function.
I'm using this query with Geomap:
import "influxdata/influxdb/schema"
from(bucket: "fleet")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> range(start: r._measurement == "points")
|> filter(fn: (r) => r._field == "lat" or r._field == "lon" or r._field == "alt" or r._field == "speed")
|> schema.fieldsAsCols()
|> group()
|> sort(columns: ["_time"])
Seems that geomap does not handle well grouped data, therefore pivoted data are ungrouped (and then sort
is needed to get correct order).