pelias / polygon-lookup

Fast point-in-polygon intersection for large numbers of polygons.
72 stars 17 forks source link

Nearest polygon #53

Open jfoclpf opened 2 years ago

jfoclpf commented 2 years ago

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 commented 2 years ago

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: