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

Nearest polygon #53

Open
jfoclpf opened this issue Aug 14, 2022 · 1 comment
Open

Nearest polygon #53

jfoclpf opened this issue Aug 14, 2022 · 1 comment

Comments

@jfoclpf
Copy link

jfoclpf commented Aug 14, 2022

When a certain point does not fit within any known polygon, is there a way to calculate or output the nearest polygon and the distance thereto?

@missinglink
Copy link
Member

Hi @jfoclpf, no, not with the current API.

It is however possible to achieve something like this using the rbush library we are using under-the-hood.
The data model is an R-Tree so you should be able to provide an input bounding-box instead of an input point.

There are a few things to note:

  • There is no way to know the minimum size bounding box you'll need to input to ensure a hit
  • The algorithm is different from the Ray Casting algo used to test a CONTAINS relationship, although its basically the same thing (ie. find the closest edge and then find the closest point on the edge).
  • Passing a bounding box which intersects many polygons will require doing work on every matching polygon, which has the potential to be considerably slower than the existing point-in-polygon API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants