Skip to main content
Version: 7.3.0

voronoi

描述

🌐 Description

接收一组点和一个边界框,并返回一组沃罗诺伊多边形。

🌐 Takes a collection of points and a bounding box, and returns a collection of Voronoi polygons.

使用的 Voronoi 算法来自 d3-voronoi 包。

🌐 The Voronoi algorithim used comes from the d3-voronoi package.

参数

🌐 Parameters

名称类型描述
pointsFeatureCollection<Point>用于计算沃罗诺伊多边形的点
options?Object可选参数 (默认 {})
options.bbox?BBox裁剪矩形,按 [minX, minY, maxX, maxY] 顺序 (默认 [-180,-85,180,-85])

返回

🌐 Returns

FeatureCollection<Polygon> 一组多边形,每个输入点对应一个

示例

🌐 Examples

const options = {
bbox: [-70, 40, -60, 60],
};
const points = turf.randomPoint(100, options);
const voronoiPolygons = turf.voronoi(points, options);

安装

🌐 Installation

$ npm install @turf/voronoi

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

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