geo.ST_LineString() function
The geo.ST_LineString()
function is experimental and subject to change at any time.
By using this function, you accept the risks of experimental functions.
The geo.ST_LineString()
function converts a series of geographic points into
linestring.
Group data into meaningful, ordered paths to before converting to linestring.
Rows in each table must have lat
and lon
columns.
Output tables contain a single row with a st_linestring
column containing the resulting linestring.
Function type: Aggregate
import "experimental/geo"
geo.ST_LineString()
Examples
Convert a series of geographic points into linestring
Input data
_time | id | lon | lat |
---|---|---|---|
2020-01-01T00:00:00Z | a213b | 39.7515 | 14.01433 |
2020-01-02T00:00:00Z | a213b | 38.3527 | 13.9228 |
2020-01-03T00:00:00Z | a213b | 36.9978 | 15.08433 |
import "experimental/geo"
data
|> geo.ST_LineString()
Output data
id | st_linestring |
---|---|
a213b | 39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433 |
Function definition
ST_LineString = (tables=<-) =>
tables
|> reduce(fn: (r, accumulator) => ({
__linestring: accumulator.__linestring + (if accumulator.__count > 0 then ", " else "") + string(v: r.lat) + " " + string(v: r.lon),
__count: accumulator.__count + 1
}), identity: {
__linestring: "",
__count: 0
}
)
|> rename(columns: {__linestring: "st_linestring"})
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.