turf-buffer icon indicating copy to clipboard operation
turf-buffer copied to clipboard

Buffering sometimes drops non-contiguous shapes

Open peterqliu opened this issue 10 years ago • 4 comments

running turf.buffer(fc, 0, 'miles') on this featurecollection

screen shot 2015-10-30 at 4 45 36 pm

gives me this:

screen shot 2015-10-30 at 4 45 29 pm

Removing the polygon to the far northeast seems to solve this problem; it's also the only poly with a hole, so that may have something to do with it.

cc/ @morganherlocker

peterqliu avatar Oct 30 '15 23:10 peterqliu

Another example, this time without visible holes. Original:

screen shot 2015-10-30 at 5 03 31 pm

turf.buffer(fc, 0, 'miles'):

screen shot 2015-10-30 at 5 04 14 pm

peterqliu avatar Oct 31 '15 00:10 peterqliu

@peterqliu this might be the same as #12. turf-buffer got some updates and is currently v1.0.4, but the main turf release is still only including v1.0.1

tcql avatar Oct 31 '15 04:10 tcql

I'm seeing the same behavior using v1.0.4 with quattroshapes' myanmar. confirmed the behavior in Mapbox Studio and QGIS:

image

studio is still chewing through the original myanmar geojson but here's the buffer -- you can see that features are missing

image

sbma44 avatar Dec 18 '15 04:12 sbma44

wound up with this workaround. pretty slow but gets the job done:

var fs = require('fs');
var buffer = require('turf-buffer');
var merge = require('turf-merge');
var polygon = require('turf-polygon');
var featurecollection = require('turf-featurecollection');

var p = JSON.parse(fs.readFileSync('quattro-myanmar.geojson'));

var out = [];
p.geometry.coordinates.forEach(function(coords, i) {
     out.push(buffer(polygon(coords), 1000, 'meters'));
});

console.log(JSON.stringify(merge(featurecollection(out))));

image

sbma44 avatar Dec 18 '15 04:12 sbma44