# lineSegment

Creates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.
从一个(多)LineString或(多)多Polygon创建一个2-vertex线段的FeatureCollection

参数

参数 类型 描述
geojson (Geometry|FeatureCollection|Feature <(LineString|MultiLineString|MultiPolygon|Polygon)>) GeoJSON Polygon or LineString

返回

FeatureCollection <LineString> - 2-vertex line segments

示例

// 注意:polygon首尾坐标要一致
var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
var segments = turf.lineSegment(polygon);
Last Updated: 1/17/2023, 5:38:58 PM