question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clustering with option minPoints 1

See original GitHub issue

With option minPoints: 1, my assumption would be that a cluster could exist with 1 point in the cluster area, but since minPoints is 1, it would have zero neighbors.

Including another if (!clusterProperties) clusterProperties = this._map(p, true); after the for loop solves this by setting the clusterProperties when no neighbors are found.

Fork with change: https://github.com/michaelfarrelly/supercluster/commit/3dbbc52fc0c7bb8a20cc52ac338f74b3c4ddfca0

If this against the purpose of this property, then I can revoke this request. My projects goal was to have clustering only (no points) when zoomed out.

https://github.com/mapbox/supercluster/blob/main/index.js#L266-L282

for (const neighborId of neighborIds) {
	const b = tree.points[neighborId];

	if (b.zoom <= zoom) continue;
	b.zoom = zoom; // save the zoom (so it doesn't get processed twice)

	const numPoints2 = b.numPoints || 1;
	wx += b.x * numPoints2; // accumulate coordinates for calculating weighted center
	wy += b.y * numPoints2;

	b.parentId = id;

	if (reduce) {
		if (!clusterProperties) clusterProperties = this._map(p, true);
		reduce(clusterProperties, this._map(b));
	}
}

=>

for (const neighborId of neighborIds) {
	const b = tree.points[neighborId];

	if (b.zoom <= zoom) continue;
	b.zoom = zoom; // save the zoom (so it doesn't get processed twice)

	const numPoints2 = b.numPoints || 1;
	wx += b.x * numPoints2; // accumulate coordinates for calculating weighted center
	wy += b.y * numPoints2;

	b.parentId = id;

	if (reduce) {
		if (!clusterProperties) clusterProperties = this._map(p, true);
		reduce(clusterProperties, this._map(b));
	}
}

if (!clusterProperties) clusterProperties = this._map(p, true);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

2reactions
shide1989commented, Nov 26, 2021

Encountered same situation BUT : My opinion is that the minPointspurpose is different from the clusterOnly purpose where the getClustersmethod should only return clusters. The goal of the minPoints options is to define the minimum of points to be able to create a Cluster. Whereas a clusterOnly options would force the algorithm to return clusters.

IMO Both parameters could be used, for ex to have clusters with a minPoints = 3 and clustersOnly = truewhere it would form normal clusters of 3 points minimum, and the other points would be clusterized in clusters of 1 point.

1reaction
FR073Ncommented, Feb 15, 2022

Same for me. clusterOnly can be a good property to have a proper display with clusters only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Density-Based Clustering Methods - GeoDa
Border points and minimum cluster size. The DBSCAN algorithm depends critically on the choice of two parameters. One is the Distance Threshold, ...
Read more >
DBSCAN: Density-Based Clustering Essentials - Datanovia
DBSCAN algorithm requires users to specify the optimal eps values and the parameter MinPts. In the R code above, we used eps =...
Read more >
DBSCAN Clustering — Explained - Towards Data Science
Clustering is a way to group a set of data points in a way that similar data points are grouped together. Therefore, clustering...
Read more >
Parameter Selection for HDBSCAN - Read the Docs
We will consider those major parameters, and consider how one may go ... The primary parameter to effect the resulting clustering is min_cluster_size...
Read more >
How to determine epsilon and MinPts parameters of DBSCAN ...
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) ... The low value of MinPts=1 does not make sense, as then every point ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found