geocluster
geocluster
finds clusters in sets of coordinates. It's a port of S-means by Brian Hann (which itself is a stdev-driven form of K-means), but with two dimensions, Earth-geodesic distance and properly working code.
Install
npm install geocluster
API
result = geocluster(coordinates[, bias])
coordinates
is an Array of [lat, lon]
pairs.
bias
is a factor the standard deviation gets multiplied with, which acts as threshold to determine if a coordinate belongs to a cluster.
result
is an Array of cluster objects, which have centroid
and elements
properties. Example:
centroid: 1010elements:1010 0911 1109centroid: 2020elements:2020 1921 2119
Sample Code
var geocluster = ;var coordinates = // array of lat-lon-pairs<lat> <lon><lat> <lon><lat> <lon>// ...;var bias = 15; // multiply stdev with this factor, the smaller the more clustersvar result = ;// result is an array of cluster objects with `centroid` and `elements` properties