Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@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 by default, see options)
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 594,343 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.