-
Notifications
You must be signed in to change notification settings - Fork 32
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
Suggestion: vtk/pyvista for spatial indexing #1124
Comments
Bit more digging: performance might be a concern. Ideally, you'd use compiled parallel for loops (like Cython or Numba I think pyvista also reinitialized the locator every query, but this can be avoided by using the vtk locator directly. |
Hi @Huite Thanks for sharing this! This does seem very relevant to a lot of the work that we've been putting together. Although, I am a little hesitant in how applicable this would be to our specific use case of spherical unstructured grids. We've been working with @hongyuchen1030 to implement many of the routines above directly on the unit sphere. We achieve The bounds are currently stored as an array, however I could imagine there are more efficient ways to organize the bounds that would reduce our query time (@hongyuchen1030 if I remember correctly, I think this is something you presented or showcased before @aaronzedwick is currently working on a Point in Polygon implementation in #1056 We have an approximate version of
This is what we've been leaning towards (Numba) for some time now, and it's been very successful.
I've glanced over this before and the implementation looks great. I could see this being useful, though my same concerns above regarding spherical geometry apply. We could however possibly utilize these packages if we chose to project our grid to 2D using something like a sterographic projection, though that also introduces some new difficulties. |
Ah I see, I had seen some methods for spherical geometries (the Gaussian quadrature methods, etc.), but hadn't realized the explicit focus so much. I suppose you have come across this? This spatial index might also be relevant, if I understand correctly: https://github.com/benbovy/pys2index In terms of inspiration, R has the simple features package which seems to enable both GEOS (Cartesian) and S2geometry (spherical). It's obviously much more akin to geopandas in terms of functionality and setup, but there's almost certainly interesting things in there, see: https://r-spatial.github.io/sf/articles/sf7.html |
Just a suggestion: I spent a fair amount of time setting up the spatial index and querying in https://github.com/Deltares/numba_celltree for specific logic (overlaps, intersections, etc.).
VTK and pyvista might be a worthwhile alternative:
Essentially all the queries you'd like are available:
It might not solve everything since I'm not sure yet what VTK supports in terms of non-Cartesian coordinates, but this makes 3D topologies very straightforward to support as well!
The text was updated successfully, but these errors were encountered: