turf icon indicating copy to clipboard operation
turf copied to clipboard

buffer creates a MultiPolygon instead of a Polygon

Open flodaniel opened this issue 2 years ago • 1 comments

Using @turf/turf 6.5.0

Given a linestring.json and a buffer size of 500 meters, turf.buffer should (as per its types) generate a Polygon. However it creates a multipolygon.json

This is the code:

   turf.buffer(lineString, bufferSize, {
                            units: "meters",
                        });

flodaniel avatar Oct 25 '23 12:10 flodaniel

+1 on this from me as well.

Buffering from a line creates a MultiPolygon where the 2 "extra" Polygons are tiny 4 point shapes that seem like mistaken projections or something similar (I'm no expert here).

An oddity in my experience as well was that it works at some buffers and doesn't at others. For the dataset I was testing it would work up to around 1000m, then have issues until around 2000m, then work as expected up to 10,000m when I stopped testing. Additionally, where the "extra" Polygons were along the line changed with the different levels of buffering, so it didn't seem to be related to a particular part of the line that was causing problems.

In the picture below the top shape is the valid Polygon that has been buffered from the line, the 2 polygons below don't seem valid with the buffer.

Image

taylorwebber avatar Jan 24 '25 10:01 taylorwebber