centerMedian
描述
🌐 Description
采用一个 FeatureCollection 的点并计算中位中心,算法上进行。中位中心被理解为从所有其他点出发所需总行程最少的点。
🌐 Takes a FeatureCollection of points and calculates the median center, algorithimically. The median center is understood as the point that is requires the least total travel from all other points.
Turfjs 有四种不同的函数用于计算一组数据的中心。每种函数根据不同的情况都有用。
🌐 Turfjs has four different functions for calculating the center of a set of data. Each is useful depending on circumstance.
@turf/center 通过找到数据范围的中点来寻找数据集的简单中心。也就是说,它将最东边和最西边的点,以及最北边和最南边的点各自平分。
@turf/center-of-mass 想象 数据集是一张纸。中心质点是纸张可以在手指尖上平衡的地方。
@turf/center-mean 对所有坐标取平均值,并生成一个尊重这些平均值的数值。与 @turf/center 不同,它对聚类和异常值很敏感。它位于数据集的统计中间,而不是地理中间。它还可以加权,意味着某些点比其他点更重要。
@turf/center-median 取平均中心,并尝试迭代地找到一个新的点,使从数据集中所有点到该点的旅行距离最小。它不像 @turf/center-mean 那样对异常值敏感,但它会被聚集的数据吸引。它同样可以加权。
参考文献
哈罗德·W·库恩 和 罗伯特·E·库恩, 《空间经济学中广义韦伯问题数值求解的高效算法》, 区域科学杂志 4卷第2期 (1962): 21–33, doi:{@link https://doi.org/10.1111/j.1467-9787.1962.tb00902.x}。
🌐 Harold W. Kuhn and Robert E. Kuenne, “An Efficient Algorithm for the Numerical Solution of the Generalized Weber Problem in Spatial Economics,” Journal of Regional Science 4, no. 2 (1962): 21–33, doi:{@link https://doi.org/10.1111/j.1467-9787.1962.tb00902.x}.
James E. Burt、Gerald M. Barber 和 David L. Rigby,《地理学初等统计学》,第3版,纽约:吉尔福德发布社,2009年,150–151页。
🌐 James E. Burt, Gerald M. Barber, and David L. Rigby, Elementary Statistics for Geographers, 3rd ed., New York: The Guilford Press, 2009, 150–151.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| features | FeatureCollection<any> | 任何 GeoJSON 特性集合 |
| options? | Object | 可选参数 (默认 {}) |
| options.weight? | string | 用于加权中心的属性名称 |
| options.tolerance? | number | 候选中位数之间距离的差异,当达到该点时算法停止迭代。(默认 0.001) |
| options.counter? | number | 如果容差不足,查找中位数的尝试次数应为多少。(默认 10)) |
返回
🌐 Returns
示例
🌐 Examples
var points = turf.points([
[0, 0],
[1, 0],
[0, 1],
[5, 8],
]);
var medianCenter = turf.centerMedian(points);
安装
🌐 Installation
$ npm install @turf/center-median
import { centerMedian } from "@turf/center-median";
const result = centerMedian(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.centerMedian(...);