I have a list of points as such
points = [(-57.213878612138828, 17.916958304169601),
(76.392039480378514, 0.060882542482108504),
(0.124176706
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):
def dist2(p1, p2):
return (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2
def fuse(points, d):
ret = []
d2 = d * d
n = len(points)
taken = [False] * n
for i in range(n):
if not taken[i]:
count = 1
point = [points[i][0], points[i][1]]
taken[i] = True
for j in range(i+1, n):
if Dist2(points[i], points[j]) < d2:
point[0] += points[j][0]
point[1] += points[j][1]
count+=1
taken[j] = True
point[0] /= count
point[1] /= count
ret.append((point[0], point[1]))
return ret