Skip to content

描述 ​

平滑 Polygon 或 MultiPolygon。基于 Chaikin's algorithm。 警告:可能创建退化多边形。

参数 ​

名称类型描述
inputPolysFeatureCollection<Polygon | MultiPolygon> | Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon待平滑的 (Multi)Polygon(s)
options?Object可选参数 (默认 {})
options.iterations?string平滑多边形的次数。值越大,多边形越平滑。 (默认 1)

返回值 ​

FeatureCollection<Polygon | MultiPolygon> 包含平滑后多边形的 FeatureCollection

示例 ​

javascript
var polygon = turf.polygon([
  [
    [11, 0],
    [22, 4],
    [31, 0],
    [31, 11],
    [21, 15],
    [11, 11],
    [11, 0],
  ],
]);

var smoothed = turf.polygonSmooth(polygon, { iterations: 3 });

安装 ​

javascript
$ npm install @turf/polygon-smooth

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

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