Skip to main content
Version: 7.0.0

centerMean

Description

Takes a Feature or FeatureCollection and returns the mean center. Can be weighted.

Parameters

NameTypeDescription
geojsonGeoJSONGeoJSON to be centered
options?ObjectOptional parameters (default {})
options.properties?ObjectTranslate GeoJSON Properties to Point (default {})
options.bbox?ObjectTranslate GeoJSON BBox to Point (default {})
options.id?ObjectTranslate GeoJSON Id to Point (default {})
options.weight?stringthe property name used to weight the center

Returns

    Feature<Point> a Point feature at the mean center point of all input features

Examples

var features = turf.featureCollection([
turf.point([-97.522259, 35.4691], { value: 10 }),
turf.point([-97.502754, 35.463455], { value: 3 }),
turf.point([-97.508269, 35.463245], { value: 5 }),
]);

var options = { weight: "value" };
var mean = turf.centerMean(features, options);

Installation

$ npm install @turf/center-mean

import { centerMean } from "@turf/center-mean";
const result = centerMean(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.centerMean(...);