-
Notifications
You must be signed in to change notification settings - Fork 154
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
[FEA]: Allow to find the K nearest points to a polygon (using quadtree) #1324
Comments
Hi @fpenarruApr! Thanks for submitting this issue - our team has been notified and we'll get back to you as soon as we can! |
Hey @fpenarruApr - Thanks for taking the time for a feature req here on cuSpatial! quadtree_point_to_nearest_linestring() might do what you need already, just want to check to see if you've tried this out for your needs. The function returns a cuDF dataframe with 3 columns:
I think you can replicate SELECT loc.*, t.name, t.geom
FROM locations loc
JOIN LATERAL (SELECT name, geom FROM geonames gn
ORDER BY loc.geom <-> gn.geom LIMIT 10) AS t ON true; With something similar to distances = cuspatial.quadtree_point_to_nearest_linestring(linestring_quad_pairs,
quadtree,
point_indices,
points,
linestrings)
top_n_distances = distances.sort(distances.distance)[:n] That assumes the input points, or input linestrings are static (ie you're comparing a single point to a lot of different linestrings) For any given point I think you'd need to do something similar to: index_of_point_p = point_p_idx
top_n_distances_for_point_p = distances[distances.point_index == index_of_point_p].sort(distances.distance)[:n] |
Hi @jarmak-nv Thanks for your help. id_building, id_hospital1, dist_hospital1, id_hospital2, dist_hospital2, id_hospital3, dist_hospital3 Later, we can assign colors to each polygon according to distances or some coefficients and see which areas could be with a bad service. |
Thanks for the great example! |
@fpenarruApr Yeah I see that now! Definitely will leave this feature request open since it's not something we directly support. We'll have to get creative here, I'll test a few things out this week and post some ideas 🌐 |
Is this a new feature, an improvement, or a change to existing functionality?
Improvement to existing functionality
How would you describe the priority of this feature request
Low priority, just an improvement
Please provide a clear description of problem you would like to solve.
Right now,
cuspatial.quadtree_point_to_nearest_linestring
allows to find the nearest point. It will be useful to find the N closest points to a feature (point, polygon or linestring)
Something similar to this article with Postgis:
https://www.crunchydata.com/blog/a-deep-dive-into-postgis-nearest-neighbor-search
Describe any alternatives you have considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: