Skip to main content
Version: Next

polygonSmooth

Description

Smooths a Polygon or MultiPolygon. Based on Chaikin's algorithm. Warning: may create degenerate polygons.

Parameters

NameTypeDescription
inputPolysFeatureCollection<Polygon | MultiPolygon> | Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon(Multi)Polygon(s) to smooth
options?ObjectOptional parameters (default {})
options.iterations?stringThe number of times to smooth the polygon. A higher value means a smoother polygon. (default 1)

Returns

FeatureCollection<Polygon | MultiPolygon> FeatureCollection containing the smoothed polygon/multipoylgons

Examples

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 });

Installation

$ npm install @turf/polygon-smooth

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

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