block by rveciana 62367908105448366d38f169e5bd3893

Using Turf to measure how far a line travels through a polygon in modern turf.js

Full Screen

Example to ilustrate this question at gis.stackoverflow.

The solution is using a combination of lineIntersect and lineSlice. The first one gives the points where the line and the polygon intersect. The second takes the part of the polyline btween the two points.

If the result is more complex (i.e. the resulting intersection is a polyline), the algorithm should be repeated for each part in the polygon.

index.html