-
Notifications
You must be signed in to change notification settings - Fork 68
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
Can I use rstar for geographic points & use a great circle distance? #135
Comments
I've wondered about that wording myself, but I think it's misleadingly restrictive based on the trait definition (https://docs.rs/rstar/0.11.0/rstar/trait.PointDistance.html). @adamreichold I know you've got some experience with distances other than Euclidean – can you help to clarify this? |
@amandasaurus Here's what I was thinking of: #48 (comment) You should be able to plug in https://docs.rs/geo/0.26.0/geo/algorithm/geodesic_distance/trait.GeodesicDistance.html squared and test it fairly easily?? |
I think the reference to "Euclidean" in the docs is misleading. Any distance metric fulfilling the usual axioms should do. (Out of the top of my head, I also don't see that we need anything beyond that, e.g. the metric does not need to be implied by a vector norm or a scalar product.) (Note though that in #48 (comment), I was indeed using the normal Euclidean distance in two-dimensional real space, I just changed the coordinates to polar coordinates and implemented the trait directly in terms of that. But the values were the same as if I would have converted my polar coordinates to Cartesian coordinates first and then used the provided implementation.) Concerning adding points twice: This is one relatively simple way to handle the periodic "boundary conditions" of the angular coordinates, but there are others if this feels contrived to you. The paper https://arxiv.org/pdf/1712.02977.pdf discusses common approaches and proposes one especially efficient way of doing it. |
On Tue, 26 Sep 2023 20:15 +02:00, Adam Reichold ***@***.***> wrote:
Concerning adding points twice: This is one relatively simple way to
handle the periodic "boundary conditions" of the angular coordinates,
but there are others if this feels contrived to you. The paper
https://arxiv.org/pdf/1712.02977.pdf discusses common approaches and
proposes one especially efficient approach.
OK, it's always good to have fast code. However I'm mostly concerned that I don't understand enough to do it right 🤣. To [ELI5](https://en.wiktionary.org/wiki/ELI5), if I add point P with `($latitude1, $longitude1)`, then I must also add `($longitude1 + 180°, $latitude)`.
How do I do it with other geo types, like `LineString`s or `MultiLineString`s?
…--
Amanda
|
I would say that this is just a translation, i.e. you add a copy of the geometry with all its constituent points translated in the same manner. The trick from the paper basically is re-parametrize you geometry to have fewer absolute and more relative and hence translation-invariant parameters so there is less work to do. But if all of your geometry is basically a bag of points, then just translating all of them should do the trick. (Of course, this then means negative angles and multiple overlap from a single piece of geometry and its mirrors, i.e. it can be inefficient, but it should still work.) |
I'm running into a similar use case. My "hypothetical" approach is to use mercator projections to translate between planar and longitude/latitude points. Is this the recommended approach? |
This paper is the clearest explanation of how to implement Lon / Lat indexing in an R{*}-tree that I've been able to find. I'm sure it's available on Sci-Hub in breach of copyright if you were to check the DOI (10.1007/978-3-642-40235-7_9) If you're not using Algorithm 1
Algorithm 2:
Some things worth noting:
EditTo expand on this a little: you would use Algorithm{1, 2} as the basis of an |
Hello @urschrei! I've been working on a solution for indexing on a spherical surface, inspired by the paper mentioned above. Would you be interested in extending the |
I have a millions of points (in latitude & longitude). I want to calculate nearest neighbour queries using great circle distance, i.e. distance in metres along the surface of the earth. Can I use rstar for this?
rstar::PointDistance::distance_2
refers to “squared euclidean distance”, which implies not. I'm unsure if #70 answers this question... I'm OK with adding points twice, but I fear I don't fully understand how to do this right...The text was updated successfully, but these errors were encountered: