PageSourceSearch

https://turfjs.org/assets/js/d6b91f0d.6f92aa4b.js

js turfjs.org collected 2026-09-24 09:14:48 UTC 8,305 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkturf_www||=[]).push([[2275],{21603(e,n,t){t.r(n),t.d(n,{assets:()=>h,contentTitle:()=>u,default:()=>m,frontMatter:()=>d,metadata:()=>r,toc:()=>p});const r=JSON.parse('{"id":"api/flattenReduce","title":"flattenReduce","description":"{() => }","source":"@site/versioned_docs/version-7.0.0/api/flattenReduce.mdx","sourceDirName":"api","slug":"/api/flattenReduce","permalink":"/docs/7.0.0/api/flattenReduce","draft":false,"unlisted":false,"editUrl":"https://github.com/Turfjs/turf-www/tree/master/versioned_docs/version-7.0.0/api/flattenReduce.mdx","tags":[],"version":"7.0.0","frontMatter":{"title":"flattenReduce"},"sidebar":"apiSidebar","previous":{"title":"flattenEach","permalink":"/docs/7.0.0/api/flattenEach"},"next":{"title":"geomEach","permalink":"/docs/7.0.0/api/geomEach"}}');var i=t(86070),o=t(67028),a=t(64776),l={};t.r(l),t.d(l,{along:()=>a.Qwm,angle:()=>a.g7h,applyFilter:()=>a.$hf,area:()=>a.Wcw,areaFactors:()=>a.i26,azimuthToBearing:()=>a.Oe8,bbox:()=>a.Qk1,bboxClip:()=>a.ywB,bboxPolygon:()=>a.kJI,bearing:()=>a.dcc,bearingToAzimuth:()=>a.u8E,bezierSpline:()=>a.vKl,booleanClockwise:()=>a.D2R,booleanConcave:()=>a.U7O,booleanContains:()=>a.yxm,booleanCrosses:()=>a.hkq,booleanDisjoint:()=>a.t5S,booleanEqual:()=>a.x0k,booleanIntersects:()=>a.lgr,booleanOverlap:()=>a.cYD,booleanParallel:()=>a.Y5$,booleanPointInPolygon:()=>a.mFO,booleanPointOnLine:()=>a.O84,booleanTouches:()=>a.UsQ,booleanValid:()=>a.hxF,booleanWithin:()=>a.Cei,buffer:()=>a.ra8,center:()=>a.gXo,centerMean:()=>a.rb,centerMedian:()=>a.eZr,centerOfMass:()=>a.NAY,centroid:()=>a.vh2,circle:()=>a.n1W,cleanCoords:()=>a.ayX,clone:()=>a.o8B,cloneProperties:()=>a.Rdw,clusterEach:()=>a.UZ0,clusterReduce:()=>a.HYf,clusters:()=>a.qf7,clustersDbscan:()=>a.Zqw,clustersKmeans:()=>a.pPd,collect:()=>a.Fod,collectionOf:()=>a.iww,combine:()=>a.kg7,concave:()=>a.Ms8,containsNumber:()=>a.lOq,convertArea:()=>a.vnt,convertLength:()=>a.I3T,convex:()=>a.y5H,coordAll:()=>a.D3w,coordEach:()=>a.Fh1,coordReduce:()=>a.k7X,createBins:()=>a.f8u,degreesToRadians:()=>a.tRv,destination:()=>a.j_,difference:()=>a.iv2,directionalMean:()=>a.eFb,dissolve:()=>a.a1F,distance:()=>a.IoC,distanceWeight:()=>a.mJ,earthRadius:()=>a.zXD,ellipse:()=>a.pw2,envelope:()=>a.REH,explode:()=>a.Gdr,factors:()=>a.PgN,feature:()=>a.N4z,featureCollection:()=>a.Lrk,featureEach:()=>a.usj,featureOf:()=>a.mo4,featureReduce:()=>a.n4j,filterProperties:()=>a.qV7,findPoint:()=>a.Yd2,findSegment:()=>a.ptW,flatten:()=>a.Bqz,flattenEach:()=>a.iwz,flattenReduce:()=>a.VJK,flip:()=>a.UUz,geojsonRbush:()=>a.sZS,geojsonType:()=>a.e8v,geomEach:()=>a.kX6,geomReduce:()=>a.jEc,geometry:()=>a.lCx,geometryCollection:()=>a.zbs,getCluster:()=>a.dB3,getCoord:()=>a.uGX,getCoords:()=>a.$Rn,getGeom:()=>a.bgk,getType:()=>a.Pwh,greatCircle:()=>a.Glg,helpers:()=>a._$r,hexGrid:()=>a.O9B,interpolate:()=>a.GWP,intersect:()=>a.y$5,invariant:()=>a.V1S,isNumber:()=>a.EtT,isObject:()=>a.Gvm,isobands:()=>a.Mii,isolines:()=>a.LNI,kinks:()=>a.nUT,length:()=>a.Bw9,lengthToDegrees:()=>a.vlv,lengthToRadians:()=>a.GfV,lineArc:()=>a.FsR,lineChunk:()=>a.W26,lineEach:()=>a.Iet,lineIntersect:()=>a.kVe,lineOffset:()=>a.uO7,lineOverlap:()=>a._Jg,lineReduce:()=>a.t0h,lineSegment:()=>a.wdR,lineSlice:()=>a.ne9,lineSliceAlong:()=>a.qMT,lineSplit:()=>a.JQ7,lineString:()=>a.wiw,lineStrings:()=>a.Nls,lineToPolygon:()=>a.gP4,mask:()=>a.dKf,meta:()=>a.mIj,midpoint:()=>a.PVF,moranIndex:()=>a.KFB,multiLineString:()=>a.NUZ,multiPoint:()=>a.kBJ,multiPolygon:()=>a.g52,nearestNeighborAnalysis:()=>a.rBB,nearestPoint:()=>a.xCI,nearestPointOnLine:()=>a.W1F,nearestPointToLine:()=>a.K9N,planepoint:()=>a.xYr,point:()=>a.zx7,pointGrid:()=>a.hq2,pointOnFeature:()=>a.QwJ,pointToLineDistance:()=>a.d4V,pointToPolygonDistance:()=>a.fJX,points:()=>a.WRA,pointsWithinPolygon:()=>a.nj9,polygon:()=>a.n1,polygonSmooth:()=>a.bmV,polygonTangents:()=>a.v4M,polygonToLine:()=>a.CNZ,polygonize:()=>a.Tz9,polygons:()=>a.qFD,projection:()=>a.Qju,propEach:()=>a.nPV,propReduce:()=>a.qBo,propertiesContainsFilter:()=>a.NLl,quadratAnalysis:()=>a.txz,radiansToDegrees:()=>a.nv6,radiansToLength:()=>a.cJD,random:()=>a.yTv,randomLineString:()=>a.lWQ,randomPoint:()=>a._eC,randomPolygon:()=>a.myJ,randomPosition:()=>a.Dxs,rectangleGrid:()=>a.K1I,rewind:()=>a.KrA,rhumbBearing:()=>
1a.Fc$,rhumbDestination:()=>a.rmV,rhumbDistance:()=>a.EUY,round:()=>a.LIG,sample:()=>a.XM1,sector:()=>a.rkH,segmentEach:()=>a.RPu,segmentReduce:()=>a.OQs,shortestPath:()=>a._6q,simplify:()=>a.CRN,square:()=>a.EwI,squareGrid:()=>a.cS4,standardDeviationalEllipse:()=>a.C0c,tag:()=>a.TcI,tesselate:()=>a.nYW,tin:()=>a.ucs,toMercator:()=>a.FU4,toWgs84:()=>a.zY8,transformRotate:()=>a.qS_,transformScale:()=>a.nIv,transformTranslate:()=>a.tLh,triangleGrid:()=>a.Vwd,truncate:()=>a.xvE,union:()=>a.KCZ,unkinkPolygon:()=>a.BoU,validateBBox:()=>a.O6s,validateId:()=>a.GZo,voronoi:()=>a.B8d});t(36796);var s=t(35876),c=t(25333);const d={title:"flattenReduce"},u=void 0,h={},p=[{value:"Description",id:"description",level:3},{value:"Parameters",id:"parameters",level:3},{value:"Returns",id:"returns",level:3},{value:"Examples",id:"examples",level:3},{value:"Installation",id:"installation",level:3}];function f(e){const n={a:"a",code:"code",h3:"h3",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.A,{children:()=>(0,i.jsx)(s.A,{turf:l})}),"\n",(0,i.jsx)(n.h3,{id:"description",children:"Description"}),"\n",(0,i.jsx)(n.p,{children:"Reduce flattened features in any GeoJSON object, similar to Array.reduce()."}),"\n",(0,i.jsx)(n.h3,{id:"parameters",children:"Parameters"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Name"}),(0,i.jsx)(n.th,{children:"Type"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"geojson"}),(0,i.jsx)(n.td,{children:(0,i.jsxs)(n.strong,{children:[(0,i.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.3",children:"FeatureCollection"})," | ",(0,i.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.2",children:"Feature"})," | ",(0,i.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.1",children:"Geometry"})]})}),(0,i.jsx)(n.td,{children:"any GeoJSON object"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"callback"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.strong,{children:"Function"})}),(0,i.jsx)(n.td,{children:"a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsxs)(n.td,{children:["initialValue",(0,i.jsx)("i",{children:"?"})]}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.strong,{children:"*"})}),(0,i.jsx)(n.td,{children:"Value to use as the first argument to the first call of the callback."})]})]})]}),"\n",(0,i.jsx)(n.h3,{id:"returns",children:"Returns"}),"\n",(0,i.jsx)("ul",{children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"*"})," The value that results from the reduction."]})}),"\n",(0,i.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-javascript",children:'var features = turf.featureCollection([\n  turf.point([26, 37], { foo: "bar" }),\n  turf.multiPoint(\n    [\n      [40, 30],\n      [36, 53],\n    ],\n    { hello: "world" },\n  ),\n]);\n\nturf.flattenReduce(\n  features,\n  function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {\n    //=previousValue\n    //=currentFeature\n    //=featureIndex\n    //=multiFeatureIndex\n    return currentFeature;\n  },\n);\n'})}),"\n",(0,i.jsx)(n.h3,{id:"installation",children:"Installation"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-javascript",children:'$ npm install @turf/meta\n\nimport { flattenReduce } from "@turf/meta";\nconst result = flattenReduce(...);\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-javascript",children:'$ npm install @turf/turf\n\nimport * as turf from "@turf/turf";\nconst result = turf.flattenReduce(...);\n'})})]})}function m(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(f,{...e})}):f(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.