voronoi
描述
¥Description
Takes a collection of points and a bounding box, and returns a collection of Voronoi polygons.
The Voronoi algorithim used comes from the d3-voronoi package.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
points | FeatureCollection<点> | points around which to calculate the Voronoi polygons |
options? | 对象 | 可选参数(默认 ) |
options.bbox? | BBox | clipping rectangle, in [minX, minY, maxX, MaxY] order (default [-180,-85,180,-85]) |
返回
¥Returns
FeatureCollection<多边形> a set of polygons, one per input point
¥FeatureCollection<Polygon> a set of polygons, one per input point
示例
¥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(...);