turf jenks module
Takes a set of features and returns an array of the Jenks Natural breaks for a given property
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 |
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
Requires nodejs.
$ npm install turf-jenks
$ npm test