Back to Influxdb

geo.totalDistance() function

content/flux/v0/stdlib/experimental/geo/totaldistance.md

latest3.7 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/experimental/geo/geo.flux#L1081-L1106 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

geo.totalDistance() calculates the total distance covered by subsequent points in each input table.

Each row must contain lat (latitude) and lon (longitude) columns that represent the geographic coordinates of the point. Row sort order determines the order in which distance between points is calculated. Use the geo.units option to specify the unit of distance to return (default is km).

Function type signature
js
(<-tables: stream[{B with lon: float, lat: float}], ?outputColumn: A) => stream[C] where C: Record

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

outputColumn

Total distance output column. Default is _value.

tables

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

Examples

Return the total distance travelled per input table

js
import "experimental/geo"

data
    |> geo.totalDistance()

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

*id_timelatlon
ABC12022-01-01T00:00:00Z85.142.2
ABC12022-01-01T01:00:00Z71.350.8
ABC12022-01-01T02:00:00Z63.162.3
ABC12022-01-01T03:00:00Z50.674.9
*id_timelatlon
DEF22022-01-01T00:00:00Z-10.8-12.2
DEF22022-01-01T01:00:00Z-16.3-0.8
DEF22022-01-01T02:00:00Z-23.212.3
DEF22022-01-01T03:00:00Z-30.424.9

Output data

*id_value
ABC14157.144498077607
*id_value
DEF24428.129653320098

{{% /expand %}} {{< /expand-wrapper >}}

Return the total distance travelled in miles

js
import "experimental/geo"

option geo.units = {distance: "mile"}

data
    |> geo.totalDistance()

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

*id_timelatlon
ABC12022-01-01T00:00:00Z85.142.2
ABC12022-01-01T01:00:00Z71.350.8
ABC12022-01-01T02:00:00Z63.162.3
ABC12022-01-01T03:00:00Z50.674.9
*id_timelatlon
DEF22022-01-01T00:00:00Z-10.8-12.2
DEF22022-01-01T01:00:00Z-16.3-0.8
DEF22022-01-01T02:00:00Z-23.212.3
DEF22022-01-01T03:00:00Z-30.424.9

Output data

*id_value
ABC12583.129833073356
*id_value
DEF22751.5122020650015

{{% /expand %}} {{< /expand-wrapper >}}