Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

turf-line-distance

Turfjs74.3kMITdeprecated3.0.12

Turf packages are now namespaced: please use @turf/line-distance instead

turf-line-distance ---

turf, linestring, length, distance, units, gis

readme

turf-line-distance

build status

turf-line-distance ---

turf.line-distance (Line, [units=miles])

Measures the length of a LineString in the specified units.

Parameters

parameter type description
Line LineString to measure
[units=miles] String optional: can be degrees, radians, miles, or kilometers

Example

var line = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [
        -77.0316696166992,
        38.878605901789236
      ],
      [
        -77.02960968017578,
        38.88194668656296
      ],
      [
        -77.02033996582031,
        38.88408470638821
      ],
      [
        -77.02566146850586,
        38.885821800123196
      ],
      [
        -77.02188491821289,
        38.88956308852534
      ],
      [
        -77.01982498168944,
        38.89236892551996
      ]
    ]
  }
};

var length = turf.lineDistance(line, 'miles');
//=length

Installation

Requires nodejs.

$ npm install turf-line-distance

Tests

$ npm test