Divides a LineString into chunks of a specified length.
npm install @turf/line-chunkDivides a [LineString][1] into chunks of a specified length.
If the line is shorter than the segment length then the original line is returned.
* geojson ([FeatureCollection][2] | [Geometry][3] | [Feature][4]<([LineString][1] | [MultiLineString][5])>) the lines to split
* segmentLength [number][6] how long to make each segment
* options [Object][7] Optional parameters (optional, default {})
* options.units Units Supports all valid Turf [Units][8] (optional, default 'kilometers')
* options.reverse [boolean][9] reverses coordinates to start the first chunked segment at the end (optional, default false)
``javascript
var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);
var chunk = turf.lineChunk(line, 15, {units: 'miles'});
//addToMap
var addToMap = [chunk];
`
Returns [FeatureCollection][2]<[LineString][1]> collection of line segments
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[2]: https://tools.ietf.org/html/rfc7946#section-3.3
[3]: https://tools.ietf.org/html/rfc7946#section-3.1
[4]: https://tools.ietf.org/html/rfc7946#section-3.2
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.5
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[8]: https://turfjs.org/docs/api/types/Units
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
---
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.
Install this single module individually:
`sh`
$ npm install @turf/line-chunk
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf