geo.ST_Length() function

The geo.ST_Length() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The geo.ST_Length() function returns the spherical length or distance of the specified geographic information system (GIS) geometry. Define distance units with the geo.units option.

*Function type: Transformation*

  1. import "experimental/geo"
  2. geo.ST_Length(
  3. geometry: {linestring: "39.7515 14.01433, 38.3527 13.9228, 36.9978 15.08433"}
  4. )
  5. // Returns 346.1023974652474 (km)

Parameters

geometry

The GIS geometry to measure. Can be either point or linestring geometry. Points will always return 0.0. See GIS geometry definitions.

*Data type: Record*

Examples

Calculate the length of geographic paths
  1. import "experimental/geo"
  2. region = {
  3. minLat: 40.51757813,
  4. maxLat: 40.86914063,
  5. minLon: -73.65234375,
  6. maxLon: -72.94921875
  7. }
  8. data
  9. |> geo.toRows()
  10. |> geo.asTracks()
  11. |> geo.ST_LineString()
  12. |> map(fn: (r) => ({
  13. r with st_length: geo.ST_Length(geometry: {linestring: r.st_linestring})
  14. }))

Related articles

functions geo GIS