@turf/length
TypeScript icon, indicating that this package has built-in type declarations

7.2.0 • Public • Published

@turf/length

length

Takes a GeoJSON and measures its length in the specified units, (Multi)Point's distance are ignored.

Parameters

  • geojson Feature<(LineString | MultiLineString)> GeoJSON to measure

  • options Object Optional parameters (optional, default {})

    • options.units string can be degrees, radians, miles, or kilometers (optional, default kilometers)

Examples

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.

Installation

Install this single module individually:

$ npm install @turf/length

Or install the all-encompassing @turf/turf module that includes all modules as functions:

$ npm install @turf/turf

Package Sidebar

Install

npm i @turf/length

Weekly Downloads

671,580

Version

7.2.0

License

MIT

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • rowanwins
  • tmcw
  • morganherlocker
  • tcql
  • mdfedderly
  • twelch
  • jamesmilneruk
  • morgan.herlocker
  • smallsaucepan