Skip to content

Latest commit

 

History

History
62 lines (38 loc) · 1.93 KB

README.md

File metadata and controls

62 lines (38 loc) · 1.93 KB

@turf/voronoi

voronoi

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<Point> points around which to calculate the Voronoi polygons

  • options Object Optional parameters (optional, default {})

    • 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 = turf.voronoi(points, options);

//addToMap
const addToMap = [voronoiPolygons, points];

Returns FeatureCollection<Polygon> a set of polygons, one per input point


This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.

Installation

Install this single module individually:

$ npm install @turf/voronoi

Or install the all-encompassing @turf/turf module that includes all modules as functions:

$ npm install @turf/turf