Skip to main content
Version: Next

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

NameTypeDescription
pointsFeatureCollection<Point>points around which to calculate the Voronoi polygons
options?ObjectOptional parameters (default {})
options.bbox?BBoxclipping rectangle, in [minX, minY, maxX, MaxY] order (default [-180,-85,180,-85])

Returns

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(...);