length
Description
Takes a GeoJSON and measures its length in the specified units, (Multi)Point's distance are ignored.
Parameters
Name | Type | Description |
---|---|---|
geojson | Feature<LineString | MultiLineString> | GeoJSON to measure |
options? | Object | Optional parameters (default {}) |
options.units? | string | can be degrees, radians, miles, or kilometers (default kilometers) |
Returns
number length of GeoJSON
Examples
var line = turf.lineString([
[115, -32],
[131, -22],
[143, -25],
[150, -34],
]);
var length = turf.length(line, { units: "miles" });
Installation
$ npm install @turf/length
import { length } from "@turf/length";
const result = length(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.length(...);