Creates line segments from a GeoJSON feature.
npm install @turf/line-segmentCreates a [FeatureCollection][1] of 2-vertex [LineString][2] segments from a
[(Multi)LineString][2] or [(Multi)Polygon][3].
* geojson [GeoJSON][4] GeoJSON Polygon or LineString
``javascript
var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
var segments = turf.lineSegment(polygon);
//addToMap
var addToMap = [polygon, segments]
`
Returns [FeatureCollection][1]<[LineString][2]> 2-vertex line segments
[1]: https://tools.ietf.org/html/rfc7946#section-3.3
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[4]: https://tools.ietf.org/html/rfc7946#section-3
---
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this single module individually:
`sh`
$ npm install @turf/line-segment
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf