3

I am trying to select all neighboring polygons in mapbox gl using turf.js and I am using

turf.intersect(poly[0], item);

And sometimes it is fine, but it looks like the input polygons data is bad, and it looks like there is some gaps between neigbour polygons coordinates(the neighbour points lat/lon doesn not match, or multipolygons), so is there any other algorithm to get the neighbour polygons? enter image description here

SERG
  • 3,907
  • 8
  • 44
  • 89

1 Answers1

2

This is working as it should. The reason it is not selecting the polygon above is because it is not a neighbor (due to bad geometry etc.).

A way to work around this bad geometry would be to buffer the polygon by a small amount and then do an intersect using the slightly larger buffered layer that will span the gaps between your existing polygons.

Worm
  • 1,313
  • 2
  • 11
  • 28