-
Notifications
You must be signed in to change notification settings - Fork 4
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
PROPOSAL: pygeos & rtree engine for geometry based selection #34
Comments
Closing for #12 |
Yes this would be nice additions! We could add adapters for those R-Tree indexes either in xoak or in 3rd party packages. Adding it in xoak would be a reasonable option for now (dependencies are optional for all adapters implemented in xoak). I'm not sure how the number of adapters would grow in the future, though.
This would be great too. That would require some work, though, as we need to extend the API of the index adapters and the (I'm re-opening this issue as I think it's worth discussing geometry based selection here - the topic #12 is too broad) |
This stems from: corteva/rioxarray#202 Currently in However, this only works for regular grids (i.e. 1 dimensional x and y coordinates that are equally spaced)
The idea of this would be to enable clipping with 2 dimensional coordinates (usually latitude and longitude) with irregular grids:
With the pygeos.STRTree, you can query for the coordinates that intersect the input geometries and get the indexes back to generate a mask you could use to clip/select data. >>> import pygeos
>>> tree = pygeos.STRtree(pygeos.creation,points(xds.longitude, xds.latitude))
>>> tree.query_bulk([pygeos.box(2, 2, 4, 4), pygeos.box(5, 5, 6, 6)]).tolist() In this scenario, there isn't really a need/benefit to use geopandas. |
I see, clipping irregular data with a list of geometries is a nice example that
In addition, there's ongoing discussion/work in #32 to expose xarray-friendly wrappers for the query methods of the adapted index objects. The challenge here would be to support the variety of the queries supported by each index (e.g., BTW, I started writing bindings for the s2geometry library here that may provide similar capabilities than |
By common API, I mean a small set of query methods, one for each kind of query, rather than a single query method for all kinds of queries. Still, for the same kind of query there might be subtle differences from one index object to another. |
I am wondering if adding support for these R-Tree based selectors would be of interest:
It would allow for selecting the points with a geometry as input.
The text was updated successfully, but these errors were encountered: