lineSegment
Description
Creates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.
Parameters
Name | Type | Description |
---|---|---|
geojson | GeoJSON | GeoJSON Polygon or LineString |
Returns
FeatureCollection<LineString> 2-vertex line segments
Examples
var polygon = turf.polygon([
[
[-50, 5],
[-40, -10],
[-50, -10],
[-40, 5],
[-50, 5],
],
]);
var segments = turf.lineSegment(polygon);
Installation
$ npm install @turf/line-segment
import { lineSegment } from "@turf/line-segment";
const result = lineSegment(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineSegment(...);