turf-center
center
Takes a FeatureCollection and returns the absolute center point of all features.
Parameters
features
FeatureCollection input features
Examples
var features = "type": "FeatureCollection" "features": "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97522259 354691 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97502754 35463455 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97508269 35463245 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97516809 35465779 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97515372 35467072 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97509363 35463053 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97511123 35466601 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97518547 35469327 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97519706 35469659 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97517839 35466998 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97508678 35464942 "type": "Feature" "properties": {} "geometry": "type": "Point" "coordinates": -97514914 35463453 ; var centerPt = turf;centerPtproperties'marker-size' = 'large';centerPtproperties'marker-color' = '#000'; var resultFeatures = featuresfeatures;var result = "type": "FeatureCollection" "features": resultFeatures; //=result
Returns Feature<Point> a Point feature at the absolute center point of all input features
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Installation
Install this module individually:
$ npm install turf-center
Or install the Turf module that includes it as a function:
$ npm install turf