I hope I am clear here, I will try to add images to help people understand my problem. I have a very simple Perlin noise lake generator:
that outputs a lake as an array of points:
[
{x: 0, y: 0},
...
]
Using a simple tracer to generate a polygon from those points. It works very well and I was happy with it until I thought of an issue that might happen and then found the issue actually did happen. When you have two separate lakes in one chunk (like this)
the polygon tracer fails to create a valid polygon. I believe the solution is to go beforehand and separate points into groups of points, I looked up how to do this but all I found was an algorithm that needed to know how many groups there was supposed to be before it could work (which I do not know). I am completely stumped and would like some advice as to where to start with this. I don't need a full code answer (I can implement it myself), but a concept would be nice.
I will still be looking around and trying things while I wait for answers although I doubt with my knowledge that I will be able to find anything useful. Oh, and my polygon tracer uses marching squares if that is important.
What you need is a Clustering algorithm. And since you say that you don't know the number of clusters beforehand, I would recommend the Mean Shift algoritm.