-
Notifications
You must be signed in to change notification settings - Fork 557
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
fast-path implementation of point-to-point distance #2038
Comments
Somewhat related I noticed the following stackoverflow question that is somewhat related, but rather about geographic distances... I also wonder why it would/can/is faster that way than the implementation in GEOS. Maybe the implementation is GEOS could be improved? |
Given the GEOS API is designed to do distance between single points, it is the best to do this kind of optimisation here. See libgeos/geos#1066 |
Also see libgeos/geos#1067 |
Thanks for opening that upstream issue, that seems to have triggered a nice speed-up ;)
Does It would be _some_overhead to have to check this (although also not that big, below for a binary case, not matrix):
Or it could be a specialized API? ( |
If I am reading that code correctly, sf checks whether the input is a subclass of
To minimise this overhead for clearly non-point arrays, you can first check for the geom type of the first element and check all only if the first one is point. Though given how tiny it is, it may not be worth the effort. I would prefer including this in |
I was looking at the differences in performance of
distance
shown in this benchmark and found out, thatsf
has a special fast path implementation of distance computation if all geometries are points on a plane - https://github.com/r-spatial/sf/blob/32aa6c8c53005245493540b1359bc35fe50f0115/R/geom-measures.R#L200-L203I think we could do the same, as if we measure the distance between points using numpy, we can get significant performance boosts. See below a replication of that benchmark using GEOS 3.12.1 and shapely main:
That is more than 50x faster than the GEOS version with identical results.
Would there be an appetite to get this implemented directly in shapely?
The text was updated successfully, but these errors were encountered: