Package Exports
- @turf/line-slice-along
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@turf/line-slice-along) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@turf/line-slice-along
lineSliceAlong
Takes a line, a specified distance along the line to a start Point, and a specified distance along the line to a stop point and returns a subsection of the line in-between those points.
This can be useful for extracting only the part of a route between two distances.
Parameters
line(Feature<LineString> | LineString) input linestartDistnumber distance along the line to starting pointstopDistnumber distance along the line to ending pointunits[string] can be degrees, radians, miles, or kilometers (optional, defaultkilometers)
Examples
var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[ 7.66845703125, 45.058001435398296 ],
[ 9.20654296875, 45.460130637921004 ],
[ 11.348876953125, 44.48866833139467 ],
[ 12.1728515625, 45.43700828867389 ],
[ 12.535400390625, 43.98491011404692 ],
[ 12.425537109375, 41.86956082699455 ],
[ 14.2437744140625, 40.83874913796459 ],
[ 14.765625, 40.681679458715635 ]
]
}
};
var start = 12.5;
var stop = 25;
var units = 'miles';
var sliced = turf.lineSliceAlong(line, start, stop, units);
//=line
//=slicedReturns Feature<LineString> sliced line
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.
Installation
Install this module individually:
$ npm install @turf/line-slice-alongOr install the Turf module that includes it as a function:
$ npm install @turf/turf