turf-line-slice-at-intersection
Slice a line whenever it intersects other features
turf.line-slice-at-intersection(line, segmenter)
Takes a LineString and a Feature to segment it by.
Any time the line intersects the feature, it will be segmented.
Parameters
parameter | type | description |
---|---|---|
line |
Feature.<LineString> | line to segment |
segmenter |
Feature | feature to segment line by |
Example
var line = "type": "Feature" "properties": {} "geometry": "type": "LineString" "coordinates": -2478515625 27235830833483856 -228515625 21967272417616712 -20390625 5003394345022162 -18984375 26357885741666065 -1494140625 48282597468669755 -11337890625 7536764322084078 -9052734375 3601142320158722 -6328125 03515602939922709 ; var poly = "type": "Feature" "properties": {} "geometry": "type": "Polygon" "coordinates": -2091796875 9882275493429953 -2267578125 6926426847059551 -21005859375 16696855009865839 -1845703125 5090944175033399 -16083984375 1845383988573187 -13798828125 8928487062665504 -2091796875 9882275493429953 ; var features = turf//=features var result = turf; resultfeatures; //=result
Returns FeatureCollection.<LineString>
, segmented lines
Installation
Requires nodejs.
$ npm install turf-line-slice-at-intersection
Tests
$ npm test