1"use strict";(globalThis.webpackChunkturf_www||=[]).push([[8414],{57562(e,n,t){t.r(n),t.d(n,{Map0:()=>j,assets:()=>m,contentTitle:()=>x,default:()=>v,frontMatter:()=>g,metadata:()=>i,toc:()=>f});const i=JSON.parse('{"id":"api/interpolate","title":"interpolate","description":"{() => }","source":"@site/versioned_docs/version-7.0.0/api/interpolate.mdx","sourceDirName":"api","slug":"/api/interpolate","permalink":"/docs/7.0.0/api/interpolate","draft":false,"unlisted":false,"editUrl":"https://github.com/Turfjs/turf-www/tree/master/versioned_docs/version-7.0.0/api/interpolate.mdx","tags":[],"version":"7.0.0","frontMatter":{"title":"interpolate"},"sidebar":"apiSidebar","previous":{"title":"sample","permalink":"/docs/7.0.0/api/sample"},"next":{"title":"isobands","permalink":"/docs/7.0.0/api/isobands"}}');var r=t(86070),s=t(67028),o=t(70156),l=t(9568),a=t(77964),d=t(64776),c={};t.r(c),t.d(c,{along:()=>d.Qwm,angle:()=>d.g7h,applyFilter:()=>d.$hf,area:()=>d.Wcw,areaFactors:()=>d.i26,azimuthToBearing:()=>d.Oe8,bbox:()=>d.Qk1,bboxClip:()=>d.ywB,bboxPolygon:()=>d.kJI,bearing:()=>d.dcc,bearingToAzimuth:()=>d.u8E,bezierSpline:()=>d.vKl,booleanClockwise:()=>d.D2R,booleanConcave:()=>d.U7O,booleanContains:()=>d.yxm,booleanCrosses:()=>d.hkq,booleanDisjoint:()=>d.t5S,booleanEqual:()=>d.x0k,booleanIntersects:()=>d.lgr,booleanOverlap:()=>d.cYD,booleanParallel:()=>d.Y5$,booleanPointInPolygon:()=>d.mFO,booleanPointOnLine:()=>d.O84,booleanTouches:()=>d.UsQ,booleanValid:()=>d.hxF,booleanWithin:()=>d.Cei,buffer:()=>d.ra8,center:()=>d.gXo,centerMean:()=>d.rb,centerMedian:()=>d.eZr,centerOfMass:()=>d.NAY,centroid:()=>d.vh2,circle:()=>d.n1W,cleanCoords:()=>d.ayX,clone:()=>d.o8B,cloneProperties:()=>d.Rdw,clusterEach:()=>d.UZ0,clusterReduce:()=>d.HYf,clusters:()=>d.qf7,clustersDbscan:()=>d.Zqw,clustersKmeans:()=>d.pPd,collect:()=>d.Fod,collectionOf:()=>d.iww,combine:()=>d.kg7,concave:()=>d.Ms8,containsNumber:()=>d.lOq,convertArea:()=>d.vnt,convertLength:()=>d.I3T,convex:()=>d.y5H,coordAll:()=>d.D3w,coordEach:()=>d.Fh1,coordReduce:()=>d.k7X,createBins:()=>d.f8u,degreesToRadians:()=>d.tRv,destination:()=>d.j_,difference:()=>d.iv2,directionalMean:()=>d.eFb,dissolve:()=>d.a1F,distance:()=>d.IoC,distanceWeight:()=>d.mJ,earthRadius:()=>d.zXD,ellipse:()=>d.pw2,envelope:()=>d.REH,explode:()=>d.Gdr,factors:()=>d.PgN,feature:()=>d.N4z,featureCollection:()=>d.Lrk,featureEach:()=>d.usj,featureOf:()=>d.mo4,featureReduce:()=>d.n4j,filterProperties:()=>d.qV7,findPoint:()=>d.Yd2,findSegment:()=>d.ptW,flatten:()=>d.Bqz,flattenEach:()=>d.iwz,flattenReduce:()=>d.VJK,flip:()=>d.UUz,geojsonRbush:()=>d.sZS,geojsonType:()=>d.e8v,geomEach:()=>d.kX6,geomReduce:()=>d.jEc,geometry:()=>d.lCx,geometryCollection:()=>d.zbs,getCluster:()=>d.dB3,getCoord:()=>d.uGX,getCoords:()=>d.$Rn,getGeom:()=>d.bgk,getType:()=>d.Pwh,greatCircle:()=>d.Glg,helpers:()=>d._$r,hexGrid:()=>d.O9B,interpolate:()=>d.GWP,intersect:()=>d.y$5,invariant:()=>d.V1S,isNumber:()=>d.EtT,isObject:()=>d.Gvm,isobands:()=>d.Mii,isolines:()=>d.LNI,kinks:()=>d.nUT,length:()=>d.Bw9,lengthToDegrees:()=>d.vlv,lengthToRadians:()=>d.GfV,lineArc:()=>d.FsR,lineChunk:()=>d.W26,lineEach:()=>d.Iet,lineIntersect:()=>d.kVe,lineOffset:()=>d.uO7,lineOverlap:()=>d._Jg,lineReduce:()=>d.t0h,lineSegment:()=>d.wdR,lineSlice:()=>d.ne9,lineSliceAlong:()=>d.qMT,lineSplit:()=>d.JQ7,lineString:()=>d.wiw,lineStrings:()=>d.Nls,lineToPolygon:()=>d.gP4,mask:()=>d.dKf,meta:()=>d.mIj,midpoint:()=>d.PVF,moranIndex:()=>d.KFB,multiLineString:()=>d.NUZ,multiPoint:()=>d.kBJ,multiPolygon:()=>d.g52,nearestNeighborAnalysis:()=>d.rBB,nearestPoint:()=>d.xCI,nearestPointOnLine:()=>d.W1F,nearestPointToLine:()=>d.K9N,planepoint:()=>d.xYr,point:()=>d.zx7,pointGrid:()=>d.hq2,pointOnFeature:()=>d.QwJ,pointToLineDistance:()=>d.d4V,pointToPolygonDistance:()=>d.fJX,points:()=>d.WRA,pointsWithinPolygon:()=>d.nj9,polygon:()=>d.n1,polygonSmooth:()=>d.bmV,polygonTangents:()=>d.v4M,polygonToLine:()=>d.CNZ,polygonize:()=>d.Tz9,polygons:()=>d.qFD,projection:()=>d.Qju,propEach:()=>d.nPV,propReduce:()=>d.qBo,propertiesContainsFilter:()=>d.NLl,quadratAnalysis:()=>d.txz,radiansToDegrees:()=>d.nv6,radiansToLength:()=>d.cJD,random:()=>d.yTv,randomLineString:()=>d.lWQ,randomPoint:()=>d._eC,randomPolygon:()=>d.myJ,randomPosition:()=>d.Dxs,rectangleGrid:()=>d.K1I,rewind:()=>d.KrA,rhumbBearing:()=>
1d.Fc$,rhumbDestination:()=>d.rmV,rhumbDistance:()=>d.EUY,round:()=>d.LIG,sample:()=>d.XM1,sector:()=>d.rkH,segmentEach:()=>d.RPu,segmentReduce:()=>d.OQs,shortestPath:()=>d._6q,simplify:()=>d.CRN,square:()=>d.EwI,squareGrid:()=>d.cS4,standardDeviationalEllipse:()=>d.C0c,tag:()=>d.TcI,tesselate:()=>d.nYW,tin:()=>d.ucs,toMercator:()=>d.FU4,toWgs84:()=>d.zY8,transformRotate:()=>d.qS_,transformScale:()=>d.nIv,transformTranslate:()=>d.tLh,triangleGrid:()=>d.Vwd,truncate:()=>d.xvE,union:()=>d.KCZ,unkinkPolygon:()=>d.BoU,validateBBox:()=>d.O6s,validateId:()=>d.GZo,voronoi:()=>d.B8d});var h=t(36796),p=t(35876),u=t(25333);const g={title:"interpolate"},x=void 0,m={};function j(){var e=o.randomPoint(30,{bbox:[50,30,70,50]});l.featureEach(e,function(e){e.properties.solRad=50*Math.random()});var n={grid:a.G(e,100,{gridType:"points",property:"solRad",units:"miles"})};return(0,r.jsx)(h.A,{addToMap:n})}const f=[{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 b(e){const n={a:"a",code:"code",em:"em",h3:"h3",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.A,{children:()=>(0,r.jsx)(p.A,{turf:c})}),"\n",(0,r.jsx)(n.h3,{id:"description",children:"Description"}),"\n",(0,r.jsxs)(n.p,{children:["Takes a set of points and estimates their 'property' values on a grid using the ",(0,r.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Inverse_distance_weighting",children:"Inverse Distance Weighting (IDW) method"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"Name"}),(0,r.jsx)(n.th,{children:"Type"}),(0,r.jsx)(n.th,{children:"Description"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"points"}),(0,r.jsx)(n.td,{children:(0,r.jsxs)(n.strong,{children:[(0,r.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.3",children:"FeatureCollection"}),"<",(0,r.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.1.2",children:"Point"}),">"]})}),(0,r.jsx)(n.td,{children:"with known value"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"cellSize"}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"number"})}),(0,r.jsx)(n.td,{children:"the distance across each grid point"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:["options",(0,r.jsx)("i",{children:"?"})]}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"Object"})}),(0,r.jsxs)(n.td,{children:["Optional parameters ",(0,r.jsx)(n.em,{children:"(default {})"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:["options.gridType",(0,r.jsx)("i",{children:"?"})]}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"string"})}),(0,r.jsxs)(n.td,{children:["defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') ",(0,r.jsx)(n.em,{children:"(default 'square')"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:["options.property",(0,r.jsx)("i",{children:"?"})]}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"string"})}),(0,r.jsxs)(n.td,{children:["the property name in ",(0,r.jsx)(n.code,{children:"points"})," from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. ",(0,r.jsx)(n.em,{children:"(default 'elevation')"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:["options.units",(0,r.jsx)("i",{children:"?"})]}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"string"})}),(0,r.jsxs)(n.td,{children:["used in calculating cellSize, can be degrees, radians, miles, or kilometers ",(0,r.jsx)(n.em,{children:"(default 'kilometers')"})]})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsxs)(n.td,{children:["options.weight",(0,r.jsx)("i",{children:"?"})]}),(0,r.jsx)(n.td,{children:(0,r.jsx)(n.strong,{children:"number"})}),(0,r.jsxs)(n.td,{children:["exponent regulating the distance-decay
1weighting ",(0,r.jsx)(n.em,{children:"(default 1)"})]})]})]})]}),"\n",(0,r.jsx)(n.h3,{id:"returns",children:"Returns"}),"\n",(0,r.jsx)("ul",{children:(0,r.jsxs)(n.p,{children:[(0,r.jsxs)(n.strong,{children:[(0,r.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.3",children:"FeatureCollection"}),"<",(0,r.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.1.2",children:"Point"})," | ",(0,r.jsx)(n.a,{href:"https://tools.ietf.org/html/rfc7946#section-3.1.6",children:"Polygon"}),">"]})," grid of points or polygons with interpolated 'property'"]})}),"\n",(0,r.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-javascript",children:'var points = turf.randomPoint(30, { bbox: [50, 30, 70, 50] });\n\n// add a random property to each point\nturf.featureEach(points, function (point) {\n point.properties.solRad = Math.random() * 50;\n});\nvar options = { gridType: "points", property: "solRad", units: "miles" };\nvar grid = turf.interpolate(points, 100, options);\n'})}),"\n","\n",(0,r.jsx)(u.A,{children:()=>(0,r.jsx)(j,{})}),"\n",(0,r.jsx)(n.h3,{id:"installation",children:"Installation"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-javascript",children:'$ npm install @turf/interpolate\n\nimport { interpolate } from "@turf/interpolate";\nconst result = interpolate(...);\n'})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-javascript",children:'$ npm install @turf/turf\n\nimport * as turf from "@turf/turf";\nconst result = turf.interpolate(...);\n'})})]})}function v(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(b,{...e})}):b(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.