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
Feature request: Add STRtree.nearest function #668
Comments
Hi @FuriousRococo , I'm not familiar with using the nearest neighbor search functions, but it looks like you're approximately on the right track. However, at https://github.com/libgeos/geos/blob/master/capi/geos_c.h.in#L1824, I see a sign that we need to use the generic method because the items in our tree are Python objects. I think you will need to give https://github.com/libgeos/geos/blob/master/capi/geos_c.h.in#L1850 a try . |
Thanks for the advice @sgillies , I think it's working now.
ctypes_declarations.py
test.py
Output |
@FuriousRococo Do you want to submit a pull requests with this new feature? |
Thanks for adding the feature @FuriousRococo. A question while trying to understand this nearest function. Say I am trying to find nearest road for a point. So the STR tree is a tree of MultiLineString roads. So in this case, is the nearest road given using the distance projected distance from the point to the MultiLineStrings? Or is it based on the smallest distance to the centroids of the MultiLineStrings representing the roads? Thank you! |
I've wrote a test and I think the nearest function check every line in MultiLineString to see if the nearest line is inside MultiLineString. Here is my script @asif-rehan
Output |
Note
Since Shapely support no more than GEOS 3.4.0 right now, it will be great to add other functions like GEOSSTRtree_nearest in GEOS 3.6.0. So I was trying to add this function by myself and meet some problems.
Problems
GEOS source code is like:
Then I added code in strtree.py, ctypes_declarations.py and test.py and tried to run the test but got the error Segmentation fault: 11
strtree.py
ctypes_declarations.py
test.py
I thought my problem is about data processing between the ctypes and geometry, so I tried to reimplement to shared_path function but still got something wrong.
Could you help me figure this out, thx!
The text was updated successfully, but these errors were encountered: