Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Difficulty manipulating polygons using Turfjs and TypeScript

I've searched all over and haven't found an answer to this issue using Turfjs and Typescript. I'm a beginner, so please forgive me if the answer is obvious. I'm trying to use turf.intersect to help me redraw a polygon so there is no longer an overlap. I probably have several mistakes in here, but the error message I get is on intersectionArray[i], saying:

Argument of type 'Position[] | Position[][]' is not assignable to parameter of type 'Position[]'. Type 'Position[][]' is not assignable to type 'Position[]'. Type 'Position[]' is not assignable to type 'Position'. Type 'Position' is not assignable to type 'number'.ts(2345)

Can anyone point me in the right direction? It looks like turf.intersect creates a polygon OR a multipolygon, but I cannot figure out how to work with the intersection after defining it.

function adjustedBoundaries(newAreaBoundaries:turf.Polygon,
  oldAreaBoundaries:turf.Polygon){
const intersection = turf.intersect(newAreaBoundaries, oldAreaBoundaries);
const intersectionArray = intersection?.geometry.coordinates;
  if(intersectionArray){
let oldAreaSpliceIndex = 0;
for(let i = 0; i < intersectionArray.length; i++){
  if(oldAreaBoundaries.coordinates.includes(intersectionArray[i])){
    intersectionArray.splice(i,1);
    oldAreaSpliceIndex = oldAreaBoundaries.coordinates.indexOf(intersectionArray[i]);
    oldAreaBoundaries.coordinates.splice(oldAreaSpliceIndex,1);
  }}
for(let i = 0; i < intersectionArray.length; i++){
  oldAreaBoundaries.coordinates.splice(oldAreaSpliceIndex,0,intersectionArray[i])
}
return oldAreaBoundaries;
}}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!