geojson-clustering
What is geojson-clustering
A tool built to allow k-means clustering of geojson data.
here
Note: A primer of geojson can be foundInstallation
$ npm i geojson-clustering
Example
const geoclustering = ;const createClusters writeClustersToFile = geoclustering; const filepath = './sampleData.geojson'; /* * geojson object must follow GEOJSON spec outlined * here: https://tools.ietf.org/html/rfc7946 */const samplegeojson = "type": "FeatureCollection" "features": ... /* * Clusters sampledata.geojson into three clusters * NOTE: maxIterations is optional (defaults to 1000) */; /* * Clusters sampledata.geojson int four clusters * and writes it to output/output.geojson */ /* * Clusters samplegeojson into seven clusters * and runs 2000 iterations * NOTE: The higher the iterations, the slower it runs */; /* * Clusters samplegeojson into three clusters * and runs 1500 iterations */ ;
Methods
createClusters(inputData, kClusters, maxIterations)
writeToFile(inputData, kClusters, maxIterations)
parameter | type | description | required | default |
---|---|---|---|---|
inputData | Object or String | Takes in a geojson object or a filepath to a .geojson file | true | --- |
kClusters | Number | The number of clusters to seperate data into | false | 3 |
maxIter | number | The number of iterations to | false | 1000 |
here
You can use sample .geojson data locatedViewing geojson data
If you want to quickly view your outputted geojson files then check out this site and upload your .geojson files.