3.0.12 • Published 9 years ago
turf-centroid v3.0.12
turf-centroid
turf centroid module
turf.centroid(features)
Takes one or more features and calculates the centroid using the arithmetic mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
Parameters
| parameter | type | description |
|---|---|---|
features | Feature\,FeatureCollection | input features |
Example
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[
[105.818939,21.004714],
[105.818939,21.061754],
[105.890007,21.061754],
[105.890007,21.004714],
[105.818939,21.004714]
]]
}
};
var centroidPt = turf.centroid(poly);
var result = {
"type": "FeatureCollection",
"features": [poly, centroidPt]
};
//=resultReturns Feature.<Point>, the centroid of the input features
Installation
Requires nodejs.
$ npm install turf-centroidTests
$ npm test3.0.12
9 years ago
3.0.10
10 years ago
3.0.7-canary.ae89c8b3
10 years ago
3.0.7
10 years ago
3.0.5-canary.4f73aa1a
10 years ago
3.0.5
10 years ago
3.0.1
10 years ago
3.0.0-canary.7879bf6c
10 years ago
3.0.0-canary.2f5f7167
10 years ago
1.1.3
10 years ago
1.1.2
11 years ago
1.1.1
11 years ago
1.1.0
11 years ago
1.0.3
11 years ago
1.0.2
11 years ago
1.0.1
11 years ago
1.0.0
11 years ago
0.1.2
11 years ago
0.1.1
12 years ago
0.1.0
12 years ago
