coordEach
Description
Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
Parameters
Name | Type | Description |
---|---|---|
geojson | FeatureCollection | Feature | Geometry | any GeoJSON object |
callback | Function | a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex) |
excludeWrapCoord? | boolean | whether 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(...);