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
Name | Type | Description |
---|---|---|
geojson | FeatureCollection | Geometry | Feature<LineString | MultiLineString> | the lines to split |
segmentLength | number | how long to make each segment |
options? | Object | Optional parameters (default {}) |
options.units? | string | units can be degrees, radians, miles, or kilometers (default 'kilometers') |
options.reverse? | boolean | reverses coordinates to start the first chunked segment at the end (default false) |
Returns
FeatureCollection<LineString> collection of line segments
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(...);