geomReduce
Description
Reduce geometry in any GeoJSON object, similar to Array.reduce().
Parameters
Name | Type | Description |
---|---|---|
geojson | FeatureCollection | Feature | GeometryObject | GeometryCollection | Feature<GeometryCollection> | any GeoJSON object |
callback | geomReduceCallback | a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) |
initialValue? | Reducer | Value to use as the first argument to the first call of the callback. |
Returns
Reducer The value that results from the reduction.
Examples
var features = turf.featureCollection([
turf.point([26, 37], { foo: "bar" }),
turf.point([36, 53], { hello: "world" }),
]);
turf.geomReduce(
features,
function (
previousValue,
currentGeometry,
featureIndex,
featureProperties,
featureBBox,
featureId,
) {
//=previousValue
//=currentGeometry
//=featureIndex
//=featureProperties
//=featureBBox
//=featureId
return currentGeometry;
},
);
Installation
$ npm install @turf/meta
import { geomReduce } from "@turf/meta";
const result = geomReduce(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.geomReduce(...);