Skip to main content
Version: 7.0.0

coordEach

Description

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

Parameters

NameTypeDescription
geojsonFeatureCollection | Feature | Geometryany GeoJSON object
callbackFunctiona method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)
excludeWrapCoord?booleanwhether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (default false)

Returns

    void

Examples

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

turf.coordEach(
features,
function (
currentCoord,
coordIndex,
featureIndex,
multiFeatureIndex,
geometryIndex,
) {
//=currentCoord
//=coordIndex
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
},
);

Installation

$ npm install @turf/meta

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

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