npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geojson-clustering

v1.1.5

Published

Clustering geoJSON with k-means

Downloads

38

Readme

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)

| 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

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.