Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@turf/convex
Advanced tools
@turf/convex is a module in the Turf.js library that allows you to compute the convex hull of a set of points. A convex hull is the smallest convex polygon that can enclose all the points in a given dataset. This is useful in various geospatial analyses, such as determining the boundary of a set of geographical points.
Compute Convex Hull
This feature allows you to compute the convex hull of a set of points. The code sample demonstrates how to create a collection of points and then compute the convex hull using the @turf/convex module.
const turf = require('@turf/turf');
const points = turf.featureCollection([
turf.point([10, 10]),
turf.point([20, 20]),
turf.point([30, 30]),
turf.point([40, 40]),
turf.point([50, 50])
]);
const convexHull = turf.convex(points);
console.log(convexHull);
hull.js is a JavaScript library for computing the convex hull of a set of 2D points. It is lightweight and easy to use, but it focuses solely on convex hull calculations, whereas @turf/convex is part of the larger Turf.js library, which offers a wide range of geospatial analysis tools.
concaveman is a fast 2D concave hull algorithm. While it focuses on concave hulls, it can also be used to compute convex hulls by setting the concavity parameter to 1. It is faster and more flexible for certain use cases compared to @turf/convex, but it is not as feature-rich in terms of geospatial analysis.
Takes a Feature or a FeatureCollection and returns a convex hull Polygon.
Internally this uses the convex-hull module that implements a monotone chain hull.
Parameters
geojson
GeoJSON input Feature or FeatureCollectionoptions
Object Optional parameters (optional, default {}
)
Examples
var points = turf.featureCollection([
turf.point([10.195312, 43.755225]),
turf.point([10.404052, 43.8424511]),
turf.point([10.579833, 43.659924]),
turf.point([10.360107, 43.516688]),
turf.point([10.14038, 43.588348]),
turf.point([10.195312, 43.755225])
]);
var hull = turf.convex(points);
//addToMap
var addToMap = [points, hull]
Returns Feature<Polygon> a convex hull
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/convex
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf convex module
The npm package @turf/convex receives a total of 447,572 weekly downloads. As such, @turf/convex popularity was classified as popular.
We found that @turf/convex 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.