Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/clusters

Package Overview
Dependencies
Maintainers
9
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/clusters

turf clusters module

  • 7.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
656K
decreased by-4.32%
Maintainers
9
Weekly downloads
 
Created

What is @turf/clusters?

@turf/clusters is a module within the Turf.js library that provides functionality for clustering geographic points. It allows you to group points based on their proximity to each other, which is useful for various geospatial analyses such as identifying hotspots, aggregating data, and simplifying visualizations.

What are @turf/clusters's main functionalities?

Cluster K-Means

This feature allows you to perform K-Means clustering on a set of points. The code sample demonstrates how to cluster a set of points into 2 clusters using the K-Means algorithm.

const turf = require('@turf/turf');

const points = turf.featureCollection([
  turf.point([0, 0]),
  turf.point([2, 2]),
  turf.point([3, 3]),
  turf.point([8, 8]),
  turf.point([8, 9]),
  turf.point([7, 7])
]);

const clustered = turf.clustersKmeans(points, {numberOfClusters: 2});
console.log(clustered);

Cluster DBSCAN

This feature allows you to perform DBSCAN clustering on a set of points. The code sample demonstrates how to cluster a set of points using the DBSCAN algorithm with a maximum distance of 5 units and a minimum of 2 points per cluster.

const turf = require('@turf/turf');

const points = turf.featureCollection([
  turf.point([0, 0]),
  turf.point([2, 2]),
  turf.point([3, 3]),
  turf.point([8, 8]),
  turf.point([8, 9]),
  turf.point([7, 7])
]);

const clustered = turf.clustersDbscan(points, 5, 2);
console.log(clustered);

Cluster Hierarchical

This feature allows you to perform hierarchical clustering on a set of points. The code sample demonstrates how to cluster a set of points using hierarchical clustering with a minimum of 2 points per cluster and a maximum distance of 5 units.

const turf = require('@turf/turf');

const points = turf.featureCollection([
  turf.point([0, 0]),
  turf.point([2, 2]),
  turf.point([3, 3]),
  turf.point([8, 8]),
  turf.point([8, 9]),
  turf.point([7, 7])
]);

const clustered = turf.clustersHierarchical(points, {minPoints: 2, maxDistance: 5});
console.log(clustered);

Other packages similar to @turf/clusters

Keywords

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc