turf.lineIntersect
What is turf.lineIntersect?
turf.lineIntersect finds all points where two line-based geometries cross. Inputs can be LineString, MultiLineString, Polygon, or MultiPolygon (the polygon's boundary is used). The result is a FeatureCollection<Point>.
turf.lineIntersect(line1, line2) → FeatureCollection<Point>When would you use turf.lineIntersect?
Use turf.lineIntersect for any "do these cross, and where?" question — detecting where a bike path crosses a river, finding intersections between two user-drawn lines on MapLibre, or building a pre-polygonize node list for a road network.
In Node.js it is a core primitive for topology construction — combined with turf.lineSplit, it lets you split a network at every crossing before calling turf.polygonize.
undefinedFAQs
Does it return overlapping segments or only point intersections?
Point intersections only. For detecting overlapping (coincident) segments, use turf.lineOverlap.
How do I install just lineIntersect?
npm install @turf/line-intersect. It depends on @turf/helpers, @turf/invariant, @turf/meta, and @turf/line-segment.
What does it do if the lines are identical?
It returns infinitely many intersection points in theory — in practice, turf.lineIntersect returns the set of segment-segment crossings found by the algorithm, which may be a small subset. Use turf.lineOverlap for coincidence detection.
Can it test polygon versus polygon?
Yes — polygon boundaries are treated as lines. For whether polygons overlap areally, use turf.booleanIntersects or turf.intersect.