# propReduce

Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.
将任何GeoJSON对象中的属性减少为单个值,类似于Array.reduce。但是,在本例中,我们延迟地运行缩减,因此没有必要使用所有属性的数组。

> npm install @turf/meta

参数

参数 类型 描述
geojson (FeatureCollection|Feature) 任何 GeoJSON 对象
callback Function 回调函数 (previousValue, currentProperties, featureIndex)
initialValue (*) 回调函数第一个参数初始值

返回

    • 简化的结果值。

示例

var features = turf.featureCollection([
    turf.point([26, 37], {foo: 'bar'}),
    turf.point([36, 53], {hello: 'world'})
]);

turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
  //=previousValue
  //=currentProperties
  //=featureIndex
  return currentProperties
});
Last Updated: 6/21/2023, 11:40:17 PM