We have a database mongodb s> 200 thousand lines, each of which contains a point (lat, lng). We would like to create a query that sets a geographical point and radius and returns a list of clusters. Each cluster is a collection of locations located next to each other.
First question: is it possible for mongodb to automatically create and maintain these clusters for us? and if so, how can we request mongodb to return clusters (rather than actual data points) for a specific geolocation. Each returned cluster will have a position and the number of actual data points (labels with reference to geometry). Basically, we would like it to return the equivalent of the k-mean clustering algorithm.
We created the geoHaystack mongodb index, which seems to be clustered rows, but not sure how we can use it to achieve the above query:
db.locations.createIndex ({'position': "geoHaystack", type: 1}, {bucketSize: 1})
Alternatively, we could dynamically use a clustering algorithm such as https://github.com/spember/geo-cluster to create these clusters, but I assume this will be a very slow process.
Any recommendations on how best to implement such a query?
mongodb geolocation geospatial
jvence
source share