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

perf(reader): replace the scipy.spatial.cKDTree with pygeos.STRtree to find the nearest node and element #894

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lyingTree
Copy link

@lyingTree lyingTree commented Mar 24, 2022

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

…o 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 OpenDrift#892
@gauteh
Copy link
Member

gauteh commented Mar 26, 2022

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.

@lyingTree
Copy link
Author

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.

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

Successfully merging this pull request may close these issues.

The difference between scipy.spatial.cKDTree and pygeos.STRtree
2 participants