Atlaslog
Atlaslog / Turf.js / API / length
Turf.js · API reference

length

Quick answer

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

Last verified 2026-11-03 · Turf.js 7.x · Cite this page
Runnable examplesChinese noteAll API topics

Description​

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

Parameters​

NameTypeDescription
geojsonFeature<LineString | MultiLineString>GeoJSON to measure
options?ObjectOptional parameters (default {})
options.units?UnitsSupports all valid Turf Units. (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(...);
TutorialsAPI index
English reference text adapted from the official Turf.js documentation, © Turf.js contributors, licensed under MIT.
Original page: https://turfjs.org/docs/api/length · Chinese note: /turf/api/length.html
Cite this page

Atlaslog (2026). length. https://www.jingweizhi.com/en/turf/api/length.html (accessed 2026-11-03).