I have a list of points as such
points = [(-57.213878612138828, 17.916958304169601),
(76.392039480378514, 0.060882542482108504),
(0.12417670682730897, 1.0417670682730924),
(-64.840321976787706, 21.374279296143762),
(-48.966302937359913, 81.336323778066188),
(11.122014925372399, 85.001119402984656),
(8.6383049769438465, 84.874829066623917),
(-57.349835526315836, 16.683634868421084),
(83.051530302006697, 97.450469562867383),
(8.5405200433369473, 83.566955579631625),
(81.620435769843965, 48.106831247886376),
(78.713027357450656, 19.547209139192304),
(82.926153287322933, 81.026080639302577)]
They are as such when plotted in red:
I now want to fuse the points that are near to each other (circles together in black). By fuse, I mean replace those points with one point that has the averages of their coordinates.
I do understand there are whole bunches of clustering techniques there to do the similar jobs. However, as you can see this is a simple task, if I am able to tune the distance threshold. So I am reluctant to use any clustering techniques. Just a simple solution would be enough.
I am using Python, if it helps.
By near, I mean the euclidean distance between them is smaller than a threshold, which can be tuned by myself. So the right top two dots will not get circled.
You can have a function, which given a distance d would fuse the points which are within distance d of a given point (by taking their average):
You could just give a radius limit and iteratively join points that are closer than that radius away. If your dataset is small enough, brute force may suffice:
Ok, here's my severly unoptimized go at a slightly more complex algorithm, which first creates a boolean proximity matrix, from that a list of clusters which is ultimately used to obtain the averaged coordinates:
(For better visualization, the circles' radii are half the threshold, i.e. points are in the same cluster if their circles merely intersect/touch one another's edge.)