1.1.5 • Published 5 years ago

geojson-clustering v1.1.5

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

geojson-clustering Build Status Coverage Status npm version

What is geojson-clustering

A tool built to allow k-means clustering of geojson data.

Note: A primer of geojson can be found here

Installation

$ npm i geojson-clustering

Example

const geoclustering = require('geojson-clustering');
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)
 */
createClusters(filepath, 3);

/*
 * Clusters sampledata.geojson int four clusters
 * and writes it to output/output.geojson
 */
writeClustersToFile(filepath, 4)

/*
 * Clusters samplegeojson into seven clusters
 * and runs 2000 iterations
 * NOTE: The higher the iterations, the slower it runs
 */
createClusters(samplegeojson, 7, 2000);

/*
 * Clusters samplegeojson into three clusters
 * and runs 1500 iterations
 */

writeClustersToFile(samplegeojson, 3, 1500);

Methods

createClusters(inputData, kClusters, maxIterations)

writeToFile(inputData, kClusters, maxIterations)

parametertypedescriptionrequireddefault
inputDataObject or StringTakes in a geojson object or a filepath to a .geojson filetrue---
kClustersNumberThe number of clusters to seperate data intofalse3
maxIternumberThe number of iterations tofalse1000

You can use sample .geojson data located here

Viewing geojson data

If you want to quickly view your outputted geojson files then check out this site and upload your .geojson files.

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago