turf-voronoi-delaunay
voronoi
Takes a FeatureCollection of points, and a bounding box, and returns a FeatureCollection
of Voronoi polygons.
The Voronoi algorithim used comes from the d3-delaunay package.
Parameters
-
points
FeatureCollection<Point> to find the Voronoi polygons around.
-
options
Options Optional parameters (optional, default {keepProperties:false,bbox:[-180,-85,180,85]}
)
options.keepProperties
boolean switch to enable/disable preservation of feature properties (optional, default false
)options.bbox
BBox clipping rectangle, in [minX, minY, maxX, MaxY] order. (optional, default [-180,-85,180,85]
)
Examples
const options = {
bbox: [-70, 40, -60, 60]
};
const points = turf.randomPoint(100, options);
const voronoiPolygons = voronoiDelaunay(points, options);
const addToMap = [voronoiPolygons, points];
Returns FeatureCollection<Polygon> a set of polygons, one per input point.
This module can be used together with the Turfjs project, an open source
module collection dedicated to geographic algorithms. It is maintained in the
Turfjs/turf repository.
Installation
Install this module:
$ npm install turf-voronoi-delaunay
To install the Turf module:
$ npm install @turf/turf