Turf.jsMisc

turf.lineOverlap

What is turf.lineOverlap?

turf.lineOverlap finds portions of two lines that are coincident — i.e. travel the same path — within a tolerance. Input can be LineString, MultiLineString, Polygon, or MultiPolygon, and the result is a FeatureCollection<LineString> of overlapping segments.

JavaScript
turf.lineOverlap(line1, line2, options?) → FeatureCollection<LineString>

Options include:

  • tolerance — distance tolerance in the given units (default 0)
  • units'kilometers' (default), 'meters', 'miles', 'nauticalmiles', 'radians', 'degrees'

When would you use turf.lineOverlap?

Use turf.lineOverlap to detect shared segments between two routes — useful for analysing duplicate bike-lane data, finding where two GPS tracks followed the same road, or identifying shared boundaries between adjacent polygons.

In Node.js ETL, it is a go-to tool for deduplicating imported line data where multiple sources contribute overlapping features (e.g., open-data road networks from multiple providers).

Code
undefined

FAQs

What does tolerance control?

The maximum separation at which two segments still count as coincident. With tolerance: 0 they must match exactly; small positive values accommodate floating-point drift and slight positional variation in real-world data.

How do I install just lineOverlap?

npm install @turf/line-overlap. It depends on @turf/helpers, @turf/nearest-point-on-line, @turf/boolean-point-on-line, @turf/meta, and @turf/line-segment.

Does it find partial overlaps?

Yes — only the coincident portion of otherwise-distinct lines is returned. Use turf.lineIntersect for point-level crossings.

How is it different from turf.lineIntersect?

lineIntersect returns points where the lines cross. lineOverlap returns the segments where they travel together. Two routes can intersect at a point without overlapping a segment, and can overlap a segment without intersecting at a distinct crossing.