Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda