Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@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 collection of points and a bounding box, and returns a collection of Voronoi polygons.
The Voronoi algorithim used comes from the d3-voronoi package.
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]
)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.
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
FAQs
turf voronoi module
The npm package @turf/voronoi receives a total of 498,374 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.