Search code examples
pythoncluster-analysisradius

Create radius-based grouping from centroid points


I have an array of latitude and longitude. Also, I have another array of centroids.

points = np.array([[33.    , 41.    ],
       [-36, 52],
       [-55, 41.277 ],
       [34.4823, 33 ],
       [-32, 41.1424],
       [34.3931, 25 ],
       [-14, 41.0576],
       [34.2395, 44],
       [-85, 51],
       [-38, 40.9793]])

centroids = np.array([[35, 42],
[31, 40]
[25, 33],
[-55, 40],
[-85, 50]])

So, I wanna cluster my array of points based on my array of centroids given a radius. Then, my array of centroids will be my centroids and will find out which points are within 10 meters of distance, for example.

I thought used K-means, but I don't know how. I would like some help here.


Solution

  • You are not clustering.

    You are classifying points to the existing centers. That is essentially 1-nearest-neighbor classification now. See also: rocchio classifier

    Now you have not specified what to do if the nearest center is too far away... But there is no pattern discovery - just neighbor search.