DEPRECATED - replaced with @turf/line-chunk
Divide a linestring into chunks of a specified length
Divides a LineString into chunks of a specified length.
parameter | type | description |
---|---|---|
line |
Feature.<LineString> | the line to split |
segment_length |
Number | how long to make each segment |
units |
String | can be degrees, radians, miles, or kilometers |
var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-86.28524780273438,
40.250184183819854
],
[
-85.98587036132812,
40.17887331434696
],
[
-85.97213745117188,
40.08857859823707
],
[
-85.77987670898438,
40.15578608609647
]
]
}
};
//=line
var result = turf.lineChunk(line, 15, 'miles');
result.features.forEach(function(ft, ind) {
ft.properties.stroke = (ind % 2 === 0) ? '#f40' : '#389979';
});
//=result
Returns FeatureCollection.<LineString>
, collection of line segments
Requires nodejs.
$ npm install turf-line-chunk
$ npm test