package
Calculates the length of a line, perfect for paths or routes.
npm install @turf/lengthGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Takes a GeoJSON and measures its length in the specified units, (Multi)Point's distance are ignored.
geojson Feature<(LineString | MultiLineString)> GeoJSON to measure
options Object Optional parameters (optional, default {})
options.units Units Supports all valid Turf Units. (optional, default kilometers)var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);
var length = turf.length(line, {units: 'miles'});
//addToMap
var addToMap = [line];
line.properties.distance = length;Returns number length of GeoJSON
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this single module individually:
$ npm install @turf/lengthOr install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turftmcw
tom@macwright.com
Estimated unpacked size across 7 packages.
608.5 kB
Includes dependencies.
5 direct dependencies.
^2.8.1
2.9.1
7.4.0
7.4.0
7.4.0
7.4.0
7.4.0
7.4.0
^7946.0.10
7946.0.16