Skip to main content
Version: 7.1.0

flattenEach

Description

Iterate over flattened features in any GeoJSON object, similar to Array.forEach.

Parameters

NameTypeDescription
geojsonFeatureCollection | Feature | Geometryany GeoJSON object
callbackFunctiona method that takes (currentFeature, featureIndex, multiFeatureIndex)

Returns

Examples

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

turf.flattenEach(
features,
function (currentFeature, featureIndex, multiFeatureIndex) {
//=currentFeature
//=featureIndex
//=multiFeatureIndex
},
);

Installation

$ npm install @turf/meta

import { flattenEach } from "@turf/meta";
const result = flattenEach(...);
$ npm install @turf/turf

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