opendrift
opendrift copied to clipboard
perf(reader): replace the scipy.spatial.cKDTree with pygeos.STRtree to find the nearest node and element
Using pygeos.STRtree method will be more efficient than scipy.spatial.cKDTree when searching for the index of the nearest node and element.
Closes #889
Thank you, have you tried to use strtree from shapely rather than from pygeos? Then we would avoid a new dependency, and pygeos will be deprecated in the future.
Thank you, have you tried to use strtree from shapely rather than from pygeos? Then we would avoid a new dependency, and pygeos will be deprecated in the future.
I have tried to use shapely to complete this function, but now it's not a good choice. I tried the shapely in 1.7.1, the main release version, and the 1.8.1.post1, the newest release version, but it's all unsatisfactory. The return in the shapely.strtree.STRtree.nearest is a geometry, and it can't return multi-value. Thus we have to reprocess this, which seriously affects the speed.
All in all, it's not a good choice now for here. But for the Shapely 2.0, we should keep paying continuous attention.