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

S2Geometry geographical point index: preliminary results #17

Closed
benbovy opened this issue Oct 20, 2020 · 1 comment
Closed

S2Geometry geographical point index: preliminary results #17

benbovy opened this issue Oct 20, 2020 · 1 comment

Comments

@benbovy
Copy link
Member

benbovy commented Oct 20, 2020

I started working on some Python/NumPy wrappers for s2geometry indexes here: https://github.com/benbovy/pys2index

I did some preliminary tests and naive benchmarks (random points) against scikit-learn's BallTree index (with Haversine metric), and the results are very promising! It might be worth to also compare it against some fast KD-Tree implementations available in Python (with appropriate coordinate system transformation).

A nice thing with s2geometry is that we could leverage additional features like:

  • setting a maximum lookup distance to speed-up queries (related to Tolerance is not working #11 and How to leverage initial guesses? #13).
  • range queries, i.e., select all points within a latitude and/or longitude range (which would work well with xarray.Dataset.sel(lat=slice(...), lon=slice(...))) ... or actually within a region of any geometry (polygon).

Build index benchmark: pys2index.S2PointIndex 3x faster than sklearn.neighbors.BallTree for 10M points.

image

Query index benchmark: pys2index.S2PointIndex 40x faster than sklearn.neighbors.BallTree for 100k points!

image

Notebook link: https://gist.github.com/benbovy/1f35c717b44791ca600655081b5b6fc3

@benbovy
Copy link
Member Author

benbovy commented Dec 17, 2020

Added adapter for this index in #28.

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

No branches or pull requests

1 participant