Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to @turf/clusters-dbscan #851

Merged
merged 7 commits into from
Jul 21, 2017
Merged

Conversation

DenisCarriere
Copy link
Member

@DenisCarriere DenisCarriere commented Jul 20, 2017

Updates to @turf/clusters-dbscan

  • Dropped array of Features input
  • Create centroids & concave polygons using clusterEach (for testing purposes only)

JSDocs

/**
 * Takes a set of {@link Point|points} and partition them into clusters according to {@link DBSCAN's|https://en.wikipedia.org/wiki/DBSCAN} data clustering algorithm.
 *
 * @name clustersDbscan
 * @param {FeatureCollection<Point>} points to be clustered
 * @param {number} maxDistance Maximum Distance between any point of the cluster to generate the clusters (kilometers only)
 * @param {string} [units=kilometers] in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers
 * @param {number} [minPoints=3] Minimum number of points to generate a single cluster,
 * points which do not meet this requirement will be classified as an 'edge' or 'noise'.
 * @returns {FeatureCollection<Point>} Clustered Points with an additional two properties associated to each Feature:
 * - {number} cluster - the associated clusterId
 * - {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
 * @example
 * // create random points with random z-values in their properties
 * var points = turf.random('point', 100, {
 *   bbox: [0, 30, 20, 50]
 * });
 * var distance = 100;
 * var clustered = turf.clustersDbscan(points, distance);
 *
 * //addToMap
 * var addToMap = clustered;
 */
module.exports = function (points, maxDistance, units, minPoints) {

Example

image

@DenisCarriere DenisCarriere self-assigned this Jul 20, 2017
@DenisCarriere DenisCarriere changed the title Drop array of features from clusters-dbscan Updates to @turf/clusters-dbscan Jul 20, 2017
@DenisCarriere
Copy link
Member Author

Made a fun interactive leaflet map with @turf/clusters-dbscan! 🎉

https://github.com/DenisCarriere/turf-example-clusters-dbscan

image

@stebogit I can try to do one for @turf/clusters-kmeans too.

@stebogit
Copy link
Collaborator

@DenisCarriere I'm astonished. That is super fun, and instructive! 😃

@DenisCarriere
Copy link
Member Author

@stebogit I showed a few friends this tonight and we just kept making clusters for about 20 minutes 😝

If I ever create another example/project with dbscan or any other clustering algorithms I'll make sure to share it here.

The entire source code to make that dbscan example is hosted here:
https://github.com/DenisCarriere/turf-example-clusters-dbscan

Pretty straightforward static website, no Webpack, no Babel, no Typescript, only vanilla Javascript + HTML.

@DenisCarriere DenisCarriere merged commit 4b1b15c into master Jul 21, 2017
@DenisCarriere DenisCarriere deleted the updates-clusters-dbscan branch July 21, 2017 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants