Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@turf/voronoi
Advanced tools
@turf/voronoi is a module within the Turf.js library that allows you to generate Voronoi diagrams from a set of points. Voronoi diagrams partition a plane into regions based on the distance to a specific set of points, which can be useful in various geospatial analyses.
Generate Voronoi Diagram
This feature allows you to generate a Voronoi diagram from a set of points. The code sample demonstrates how to create Voronoi polygons using a bounding box to limit the extent of the diagram.
const turf = require('@turf/turf');
const points = turf.points([
[-75.343, 39.984],
[-75.833, 39.284],
[-75.534, 39.123],
[-75.123, 39.567]
]);
const bbox = [-80, 30, -70, 50];
const voronoiPolygons = turf.voronoi(points, {bbox: bbox});
console.log(JSON.stringify(voronoiPolygons));
d3-voronoi is a module within the D3.js library that provides tools for computing Voronoi diagrams. It is highly customizable and integrates well with D3's powerful data visualization capabilities. Compared to @turf/voronoi, d3-voronoi is more focused on visualization and less on geospatial analysis.
voronoi-diagram is a lightweight npm package for generating Voronoi diagrams. It is simple to use and can be a good alternative if you need a straightforward solution for creating Voronoi diagrams without the additional geospatial functionalities provided by @turf/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-voronoi package.
Parameters
points
FeatureCollection<Point> to find the Voronoi polygons around.options
Object Optional parameters (optional, default {}
)
Examples
var options = {
bbox: [-70, 40, -60, 60]
};
var points = turf.randomPoint(100, options);
var voronoiPolygons = turf.voronoi(points, options);
//addToMap
var 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.
Install this module individually:
$ npm install @turf/voronoi
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf voronoi module
The npm package @turf/voronoi receives a total of 581,949 weekly downloads. As such, @turf/voronoi popularity was classified as popular.
We found that @turf/voronoi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.