turf.lineSplit
What is turf.lineSplit?
turf.lineSplit splits a LineString wherever it intersects another GeoJSON feature — point, line, or polygon — and returns the resulting parts as a FeatureCollection<LineString>.
turf.lineSplit(line, splitter) → FeatureCollection<LineString>When would you use turf.lineSplit?
Use turf.lineSplit when you need to decompose a route by intersections with other features — splitting a road at every river crossing, cutting a trail at administrative boundaries, or slicing a boundary line at marker points.
In Node.js, turf.lineSplit is the standard step before polygonising a road network: iterate all intersecting pairs found by turf.lineIntersect, split each line at those points, and feed the noded network into turf.polygonize.
import lineSplit from '@turf/line-split';FAQs
What splitter types are supported?
Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. Polygon boundaries are treated as lines.
How do I install just lineSplit?
npm install @turf/line-split. It depends on @turf/helpers, @turf/invariant, @turf/nearest-point-on-line, @turf/line-segment, @turf/line-intersect, and @turf/meta.
Are the split points added as vertices?
Yes — every intersection becomes the endpoint of one part and the start of the next, ensuring the pieces reconnect cleanly at the cut.
Do parts preserve direction?
Yes — the output parts are ordered in the direction of the source line and each part preserves that orientation.