Skip to main content
Version: 7.0.0

geomEach

Description

Iterate over each geometry in any GeoJSON object, similar to Array.forEach()

Parameters

NameTypeDescription
geojsonFeatureCollection | Feature | Geometryany GeoJSON object
callbackFunctiona method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)

Returns

    void

Examples

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

turf.geomEach(
features,
function (
currentGeometry,
featureIndex,
featureProperties,
featureBBox,
featureId,
) {
//=currentGeometry
//=featureIndex
//=featureProperties
//=featureBBox
//=featureId
},
);

Installation

$ npm install @turf/meta

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

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