Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@turf/union : ambiguity in the documentation #2657

Open
Cooya opened this issue Jul 18, 2024 · 3 comments
Open

@turf/union : ambiguity in the documentation #2657

Cooya opened this issue Jul 18, 2024 · 3 comments

Comments

@Cooya
Copy link

Cooya commented Jul 18, 2024

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.

@twelch
Copy link
Collaborator

twelch commented Jul 18, 2024

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, ...]))

@twelch twelch added dependencies Pull requests that update a dependency file docs and removed dependencies Pull requests that update a dependency file labels Jul 18, 2024
@Cooya
Copy link
Author

Cooya commented Jul 19, 2024

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.

@Cooya Cooya closed this as completed Jul 19, 2024
@twelch twelch reopened this Jul 19, 2024
@twelch
Copy link
Collaborator

twelch commented Jul 19, 2024

Thanks, let’s leave this open for improvement of the docs, multiple people have stumbled here since v7 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants