[GIS] How to find the nearest polygon from a given point

geometrygoogle mapsgoogle-maps-api

Basically I have set of points [lat-long pairs] which define different polygons on a map. Now I have a coordinate [lat-long] from which I want to find the nearest polygon from that point.

Best Answer

There are two approaches. One is brute-force: write code to find the distance between a point and a polygon, and then iterate over all polygons. The second involves building efficient data structures, an arduous process.

For the first approach, you might look at this Wolfram Demonstration Project for computing the distance from a point to a polygon. Link here; image below. Note that sometimes the min distance is achieved at a point interior to an edge of the polygon.
           Min distance to polygon

Related Question