Skip to main content
Version: 7.0.0

lineEach

Description

Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.

Parameters

NameTypeDescription
geojsonGeometry | Feature<LineString | Polygon | MultiLineString | MultiPolygon>object
callbackFunctiona method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)

Returns

Examples

var multiLine = turf.multiLineString([
[
[26, 37],
[35, 45],
],
[
[36, 53],
[38, 50],
[41, 55],
],
]);

turf.lineEach(
multiLine,
function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
//=currentLine
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
},
);

Installation

$ npm install @turf/meta

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

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