turf.intersection slower on v7.2.0 #2810
-
I wasn't sure if I should post this as an issue, so I'm posting as a discussion. I've noticed that turf.intersection has gotten significantly slower since v7.2.0. In the below example, I'm computing the intersection between square grids and the country Saudi Arabia. I print out the time it takes to compute the intersection of each grid. Under v7.2.0, it takes roughly 340 ms to execute all of the calls to turf.intersect. Under v7.1.0, it takes around 30 ms. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for starting the discussion. Turf in 7.2.0 switched from using the polygon-clipping library to the polyclip-ts fork, which trades speed for floating point accuracy, resolving a lot of issues - #2729. If you need the performance back I would suggest trying to use the polygon-clipping package directly. I see you are also calling intersect for each grid feature on the saudi arabia polygon. Consider seeing if you can boil this down to a single intersect call. Maybe merge your grid polygons into a single multipolygon. Then call |
Beta Was this translation helpful? Give feedback.
Thanks for starting the discussion. Turf in 7.2.0 switched from using the polygon-clipping library to the polyclip-ts fork, which trades speed for floating point accuracy, resolving a lot of issues - #2729. If you need the performance back I would suggest trying to use the polygon-clipping package directly.
I see you are also calling intersect for each grid feature on the saudi arabia polygon. Consider seeing if you can boil this down to a single intersect call. Maybe merge your grid polygons into a single multipolygon. Then call
intersect(saudiArabia, gridMultiPoly)
.