Skip to content

描述 ​

将 Polygon 转换为 (Multi)LineString 或将 MultiPolygon 转换为 (Multi)LineString 的 FeatureCollection。

参数 ​

名称类型描述
polyFeature<Polygon | MultiPolygon>待转换的要素
options?Object可选参数 (默认 {})
options.properties?Object将 GeoJSON 属性转换到 Feature (默认 {})

返回值 ​

FeatureCollection | Feature<LineString | MultiLinestring> 转换后的 (Multi)Polygon 为 (Multi)LineString

示例 ​

javascript
var poly = turf.polygon([
  [
    [125, -30],
    [145, -30],
    [145, -20],
    [125, -20],
    [125, -30],
  ],
]);

var line = turf.polygonToLine(poly);

安装 ​

javascript
$ npm install @turf/polygon-to-line

import { polygonToLine } from "@turf/polygon-to-line";
const result = polygonToLine(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.polygonToLine(...);