turf-jenks

turf jenks module


Keywords
turf, geojson, jenks, classification
License
MIT
Install
npm install turf-jenks@0.1.1

Documentation

turf-jenks

build status

turf jenks module

turf.jenks(input, field, numberOfBreaks)

Takes a set of features and returns an array of the Jenks Natural breaks for a given property

Parameters

parameter type description
input FeatureCollection input features
field String the property in input on which to calculate Jenks natural breaks
numberOfBreaks Number number of classes in which to group the data

Example

var points = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "population": 200
      },
      "geometry": {
        "type": "Point",
        "coordinates": [49.859733, 40.400424]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 600
      },
      "geometry": {
        "type": "Point",
        "coordinates": [49.83879, 40.401209]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 100
      },
      "geometry": {
        "type": "Point",
        "coordinates": [49.817848, 40.376889]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 200
      },
      "geometry": {
        "type": "Point",
        "coordinates": [49.840507, 40.386043]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 300
      },
      "geometry": {
        "type": "Point",
        "coordinates": [49.854583, 40.37532]
      }
    }
  ]
};

var breaks = turf.jenks(points, 'population', 3);

//=breaks

Returns Array.<number>, the break number for each class plus the minimum and maximum values

Installation

Requires nodejs.

$ npm install turf-jenks

Tests

$ npm test