New turf union returns a strange Polygon.
See original GitHub issueI am trying to unite two polygons. First https://gist.github.com/ilijaz/e4fc41abb6e12fe9f346434a06d948db Second https://gist.github.com/ilijaz/c7fb49ad134173ce6b502dbcc449ffa9 Also first polygon created after union of some as second polygons.
const union = require('@turf/union').default;
const turf = require('@turf/turf');
const first = {"..."};
const second = {"..."};
const un1 = union(first, second);
console.log(turf.area(un1), turf.area(first), turf.area(second))
I’ve had https://gist.github.com/ilijaz/51b426f9131ab29141bf2a6660e6ad77 as result. You can see it’s wrong.
1334311.8920525517 20866.04727530979 268.7401291002204
Is it problem of tolerance? Is it normal that polygon has LinearRings that do not form a closed LlineString. They have only two coordinates.
Opposite of this case, union function from turf/turf works fine for me but it’s about 2 times slowly. Here result on same input data https://gist.github.com/ilijaz/78997225ea130a0a1db1b40990f90237
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Turfjs/turf - Gitter
Hi, you may iterate your data, check boolean-point-in-polygon and returns polygon ... @benboughton1 Very strange, in source code dissolve using union .
Read more >Advanced geospatial analysis - Turf.js
union. Takes two (Multi)Polygon(s) and returns a combined polygon. If the input polygons are not contiguous, this function returns a MultiPolygon feature.
Read more >How to use the @turf/union function in @turf/union - Snyk
To help you get started, we've selected a few @turf/union examples, based on popular ways it is used in public projects. ; type:...
Read more >Shared edge between two geojson polygons
Takes two polygons and finds their intersection. If they share a border, returns the border; if they don't intersect, returns undefined.
Read more >Turf.js pointsWithinPolygon - creating a usable array
in the house loading function you say that you want to load a polygon but you create point feature, this will not working....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resolved since v6.2.0
Indeed. The bug is that here the algorithm assumes multiple polygons are separate but in this case they should not be split up as the second one is a hole in the first one. https://github.com/Turfjs/turf/blob/a371807f78364820f15ab8f9ee3dc5aba51b7bac/packages/turf-union/index.ts#L47