Skip to main content
Version: 6.5.0

lineChunk

Description

Divides a LineString into chunks of a specified length. If the line is shorter than the segment length then the original line is returned.

Parameters

NameTypeDescription
geojsonFeatureCollection | Geometry | Feature<LineString | MultiLineString>the lines to split
segmentLengthnumberhow long to make each segment
options?ObjectOptional parameters (default {})
options.units?stringunits can be degrees, radians, miles, or kilometers (default 'kilometers')
options.reverse?booleanreverses coordinates to start the first chunked segment at the end (default false)

Returns

Examples

var line = turf.lineString([
[-95, 40],
[-93, 45],
[-85, 50],
]);

var chunk = turf.lineChunk(line, 15, { units: "miles" });

Installation

$ npm install @turf/line-chunk

import { lineChunk } from "@turf/line-chunk";
const result = lineChunk(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.lineChunk(...);