Open Cooya opened 1 month ago
I agree the API docs don't look quite right. That said, you can union more than 2 polygons. You can include as many polygons as you want in your featureCollection input. This is as of Turf 7.0
var union = turf.union(turf.featureCollection([poly1, poly2, poly3, ...]))
My bad, turf.union() can actually union more than 2 polygons and works like a charm. It was a mistake in my code. My apologies for the inconvenience. I am closing the issue.
Thanks, let’s leave this open for improvement of the docs, multiple people have stumbled here since v7 release
turf.union() can only merge 2 polygons at once (https://stackoverflow.com/questions/68005988/geojson-turf-merge-multiple-polygons-to-one-polygon-keeping-hole). It should be specified in the documentation (https://www.npmjs.com/package/@turf/union) and in the TypeScript interface file to avoid invalid merges with more than 2 polygons.