Skip to content

描述 ​

接收一个 Feature 或 FeatureCollection,返回凸包 Polygon。

内部使用 convex-hull 模块,该模块实现了 monotone chain hull。

参数 ​

名称类型描述
geojsonGeoJSON输入 Feature 或 FeatureCollection
options?Object可选参数 (默认 {})
options.concavity?number1 - 薄形。Infinity - 凸包。(默认 Infinity)
options.properties?Object将属性转换到 Feature (默认 {})

返回值 ​

Feature<Polygon> 凸包

示例 ​

javascript
var points = turf.featureCollection([
  turf.point([10.195312, 43.755225]),
  turf.point([10.404052, 43.8424511]),
  turf.point([10.579833, 43.659924]),
  turf.point([10.360107, 43.516688]),
  turf.point([10.14038, 43.588348]),
  turf.point([10.195312, 43.755225]),
]);

var hull = turf.convex(points);

安装 ​

javascript
$ npm install @turf/convex

import { convex } from "@turf/convex";
const result = convex(...);
javascript
$ npm install @turf/turf

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