Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@turf/clusters-dbscan
Advanced tools
@turf/clusters-dbscan is a module from the Turf.js library that provides functionality for clustering geographical points using the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm. This is useful for identifying clusters of points in spatial data, which can be applied in various fields such as geographic information systems (GIS), urban planning, and environmental monitoring.
Cluster Points
This feature allows you to cluster geographical points based on their proximity to each other. The code sample demonstrates how to create a collection of points and then apply the DBSCAN algorithm to identify clusters within a specified distance (0.3 units) and a minimum number of points (2) to form a cluster.
const turf = require('@turf/turf');
const points = turf.featureCollection([
turf.point([0, 0]),
turf.point([0.1, 0.1]),
turf.point([0.2, 0.2]),
turf.point([10, 10]),
turf.point([10.1, 10.1])
]);
const clustered = turf.clustersDbscan(points, 0.3, { minPoints: 2 });
console.log(clustered);
Identify Noise Points
This feature helps in identifying noise points, which are points that do not belong to any cluster. The code sample shows how to filter out noise points from the clustered result.
const turf = require('@turf/turf');
const points = turf.featureCollection([
turf.point([0, 0]),
turf.point([0.1, 0.1]),
turf.point([0.2, 0.2]),
turf.point([10, 10]),
turf.point([10.1, 10.1])
]);
const clustered = turf.clustersDbscan(points, 0.3, { minPoints: 2 });
const noisePoints = clustered.features.filter(feature => feature.properties.cluster === 'noise');
console.log(noisePoints);
Supercluster is a fast geospatial point clustering library for browsers and Node. It is designed for visualizing large datasets on maps by clustering points into clusters of varying sizes. Unlike @turf/clusters-dbscan, which uses the DBSCAN algorithm, Supercluster uses a hierarchical clustering approach optimized for map rendering.
KDBush is a very fast static spatial index for 2D points based on a flat KD-tree. It is used for indexing and querying points in 2D space. While it does not perform clustering like @turf/clusters-dbscan, it can be used in conjunction with clustering algorithms to efficiently query and manage spatial data.
Geocluster is a simple clustering library for geographical points. It uses a different clustering approach compared to DBSCAN and is designed to be easy to use for basic clustering needs. It is less feature-rich compared to @turf/clusters-dbscan but can be a good choice for simpler use cases.
Takes a set of points and partition them into clusters according to https://en.wikipedia.org/wiki/DBSCAN data clustering algorithm.
points
FeatureCollection<Point> to be clustered
maxDistance
number Maximum Distance between any point of the cluster to generate the clusters (kilometers only)
options
Object Optional parameters (optional, default {}
)
options.units
string in which maxDistance
is expressed, can be degrees, radians, miles, or kilometers (optional, default "kilometers"
)options.mutate
boolean Allows GeoJSON input to be mutated (optional, default false
)options.minPoints
number Minimum number of points to generate a single cluster,
points which do not meet this requirement will be classified as an 'edge' or 'noise'. (optional, default 3
)// create random points with random z-values in their properties
var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]});
var maxDistance = 100;
var clustered = turf.clustersDbscan(points, maxDistance);
//addToMap
var addToMap = [clustered];
Returns FeatureCollection<Point> Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId
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/clusters-dbscan
Or install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf
FAQs
turf clusters-dbscan module
The npm package @turf/clusters-dbscan receives a total of 341,809 weekly downloads. As such, @turf/clusters-dbscan popularity was classified as popular.
We found that @turf/clusters-dbscan demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.