Clustering points

Hello all

Im not sure how to approach this one. The idea is to start with a bunch of points (say 100).

I want to find groups of points among the total set. So for example have an input of 5 and the definition finds 5 groups of equal size among the total 100. I am ultimately interested in finding “groups” that are clusters of points such that the cluster is made up of a subset of points that are the close to other points. Ill attach a simplified sketch with 30 points of what I mean below because that might not have been clear.

In the end the idea is to interpolate the external points of a cluster so that each group is enclosed by a curve that isnt intersected by another group’s exterior curve. (Kind of similar to “The Potato Plan” by Kees Christiaanse)

In the future the idea is to apply this to a 3D point cloud with a brep shell around them instead of a curve around a 2D point set, but I think its smart to start simple.

Any ideas how to approach this?

Thank you very much ahead of time to all those that give input :slight_smile:


I don’t have a lot for you but I believe you’re looking for an implementation of K-means clustering. That might help in searching.

or perhaps the Point Group + Convex Hull components will suffice


ptgroup_convexuhll.gh (17.3 KB)

I thought this might be the way to go, but I cant figure out how to use the component or make a definition from it, and theres limited information about it online.

Lets say pop2d > kmeans gives an error of "data failed conversion of points to tensorset.

Any pointers?

Ive read through this https://www.grasshopper3d.com/forum/topics/kmeans-1

but theres no clear explanation there

I recode the component from your link

It works very well, in 2D or 3D and it is very simple, not many thinks to look at. I will try to rewrite it in C#.


k_mean2.ghx (374.8 KB)

Like advised by David here a version, without random seed, in C#, without datatree as Input. It seems to work well but I had not tested it a lot. It gives the same result as the VB component.


k_mean2.ghx (410.3 KB)

12 Likes