All Projects → mapbox → Supercluster

mapbox / Supercluster

Licence: isc
A very fast geospatial point clustering library for browsers and Node.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Supercluster

Delaunator Cpp
A really fast C++ library for Delaunay triangulation of 2D points
Stars: ✭ 244 (-80.42%)
Mutual labels:  algorithm, computational-geometry
React Native Maps Super Cluster
A Clustering-enabled map for React Native
Stars: ✭ 284 (-77.21%)
Mutual labels:  clustering, maps
Geokdbush
The fastest spatial index for geographic locations in JavaScript
Stars: ✭ 251 (-79.86%)
Mutual labels:  algorithm, computational-geometry
Rbush
RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
Stars: ✭ 1,881 (+50.96%)
Mutual labels:  algorithm, computational-geometry
Phpalgorithms
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell
Stars: ✭ 865 (-30.58%)
Mutual labels:  algorithm, maps
Greinerhormann
Greiner-Hormann polygon clipping algorithm. Does AND, OR, XOR. Plays nicely with Leaflet. Handles non-convex polygons and multiple clipping areas. ~3kb footprint, no dependencies
Stars: ✭ 176 (-85.87%)
Mutual labels:  algorithm, computational-geometry
react-map-gl-cluster
Urbica React Cluster Component for Mapbox GL JS
Stars: ✭ 27 (-97.83%)
Mutual labels:  maps, clustering
Delaunator
An incredibly fast JavaScript library for Delaunay triangulation of 2D points
Stars: ✭ 1,641 (+31.7%)
Mutual labels:  algorithm, computational-geometry
Turf
A modular geospatial engine written in JavaScript
Stars: ✭ 6,659 (+434.43%)
Mutual labels:  algorithm, computational-geometry
React Native Map Clustering
React Native map clustering both for Android and iOS.
Stars: ✭ 450 (-63.88%)
Mutual labels:  clustering, maps
Cavaliercontours
2D polyline library for offsetting, combining, etc.
Stars: ✭ 135 (-89.17%)
Mutual labels:  algorithm, computational-geometry
Clustering
fast clustering algorithms
Stars: ✭ 14 (-98.88%)
Mutual labels:  algorithm, clustering
Data structure and algorithms library
A collection of classical algorithms and data-structures implementation in C++ for coding interview and competitive programming
Stars: ✭ 133 (-89.33%)
Mutual labels:  algorithm, computational-geometry
Skeleton Tracing
A new algorithm for retrieving topological skeleton as a set of polylines from binary images
Stars: ✭ 241 (-80.66%)
Mutual labels:  algorithm, computational-geometry
Turf Swift
A Swift language port of Turf.js.
Stars: ✭ 123 (-90.13%)
Mutual labels:  algorithm, computational-geometry
js-markerclusterer
Create and manage clusters for large amounts of markers
Stars: ✭ 92 (-92.62%)
Mutual labels:  maps, clustering
Ml
A high-level machine learning and deep learning library for the PHP language.
Stars: ✭ 1,270 (+1.93%)
Mutual labels:  algorithm, clustering
Earcut
The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
Stars: ✭ 1,359 (+9.07%)
Mutual labels:  algorithm, computational-geometry
Kdbush
A fast static index for 2D points
Stars: ✭ 412 (-66.93%)
Mutual labels:  algorithm, computational-geometry
Polysnap
A work in progress polygon operations library with integer snap-rounding
Stars: ✭ 14 (-98.88%)
Mutual labels:  algorithm, computational-geometry

supercluster Simply Awesome Build Status

A very fast JavaScript library for geospatial point clustering for browsers and Node.

<script src="https://unpkg.com/[email protected]/dist/supercluster.min.js"></script>
const index = new Supercluster({
    radius: 40,
    maxZoom: 16
});
index.load(points);
index.getClusters([-180, -85, 180, 85], 2);

Clustering 6 million points in Leaflet:

clusters2

Install

Install using NPM (npm install supercluster) or Yarn (yarn add supercluster), then:

// import as a ES module
import Supercluster from 'supercluster';

// or require in Node / Browserify
const Supercluster = require('supercluster');

Or use a browser build directly:

<script src="https://unpkg.com/[email protected]/dist/supercluster.min.js"></script>

Methods

load(points)

Loads an array of GeoJSON Feature objects. Each feature's geometry must be a GeoJSON Point. Once loaded, index is immutable.

getClusters(bbox, zoom)

For the given bbox array ([westLng, southLat, eastLng, northLat]) and integer zoom, returns an array of clusters and points as GeoJSON Feature objects.

getTile(z, x, y)

For a given zoom and x/y coordinates, returns a geojson-vt-compatible JSON tile object with cluster/point features.

getChildren(clusterId)

Returns the children of a cluster (on the next zoom level) given its id (cluster_id value from feature properties).

getLeaves(clusterId, limit = 10, offset = 0)

Returns all the points of a cluster (given its cluster_id), with pagination support: limit is the number of points to return (set to Infinity for all points), and offset is the amount of points to skip (for pagination).

getClusterExpansionZoom(clusterId)

Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster's cluster_id.

Options

Option Default Description
minZoom 0 Minimum zoom level at which clusters are generated.
maxZoom 16 Maximum zoom level at which clusters are generated.
minPoints 2 Minimum number of points to form a cluster.
radius 40 Cluster radius, in pixels.
extent 512 (Tiles) Tile extent. Radius is calculated relative to this value.
nodeSize 64 Size of the KD-tree leaf node. Affects performance.
log false Whether timing info should be logged.
generateId false Whether to generate ids for input features in vector tiles.

Property map/reduce options

In addition to the options above, supercluster supports property aggregation with the following two options:

  • map: a function that returns cluster properties corresponding to a single point.
  • reduce: a reduce function that merges properties of two clusters into one.

Example of setting up a sum cluster property that accumulates the sum of myValue property values:

const index = new Supercluster({
    map: (props) => ({sum: props.myValue}),
    reduce: (accumulated, props) => { accumulated.sum += props.sum; }
});

Note that reduce must not mutate the second argument (props).

Developing Supercluster

npm install       # install dependencies
npm run build     # generate dist/supercluster.js and dist/supercluster.min.js
npm test          # run tests
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].