pyufunc.find_closest_point#
- pyufunc.find_closest_point(pt, pts, k_closest=1)#
Find the closest point from a list of reference points.
- Parameters:
pt (Point) – the point to start with
pts (MultiPoint) – list of reference points in the format of shapely.MultiPoint
k_closest (int) – k closest points for each starting point. Defaults to 1.
- Returns:
list of k closest points for each point
- Return type:
Example
>>> from shapely.geometry import Point, MultiPoint >>> pt = Point(0, 0) >>> pts = MultiPoint([(1, 1), (2, 2), (3, 3)]) >>> find_closest_point(pt, pts) [POINT (1 1)]
>>> find_closest_point(pt, pts, k_closest=5) [POINT (1 1), POINT (2 2), POINT (3 3)]
Note
- This function is modified from the original code available at:
The function return the close point but not distance.
Because of unit issue, the distance can be calculated by calc_distance_on_unit_sphere.