diff_idx = np.flatnonzero(np.linalg.norm(b[1:] - b[:-1], axis=1) > thresh) + 1
idx = np.hstack((0, diff_idx, b.shape[0]))
sums = np.add.reduceat(b, idx[:-1])
counts = idx[1:] - idx[:-1]
out = sums / counts.astype(float)[:, (None)]
Средние ближайшие координаты в Python