earthkit.geo.distance.nearest_point_kdtree¶
- earthkit.geo.distance.nearest_point_kdtree(ref_points, points, figure=IFS_SPHERE)¶
Find the index of the nearest point to all
ref_pointsin a set ofpointsusing a KDTree.- Parameters:
ref_points (
pairofarray-like) – Latitude and longitude coordinates of the reference point (degrees)points (
pairofarray-like) – Locations of the set of points from which the nearest toref_pointsis to be found. The first item specifies the latitudes, the second the longitudes (degrees)figure (
geo.figure.Figure, optional) – Figure of the spheroid the returned distances are computed on (default:geo.figure.IFS_SPHERE)
- Returns:
ndarray– Indices of the nearest points toref_points.ndarray– The distance (m) between theref_pointsand the corresponding nearest point inpoints. Computed on the surface of the spheroid defined byfigure.
Examples
>>> from earthkit.geo import nearest_point_kdtree >>> p_ref = (51.45, -0.97) >>> p_lat = [44.49, 50.73, 50.1] >>> p_lon = [11.34, 7.90, -8.1] >>> nearest_point_kdtree(p_ref, (p_lat, p_lon)) (array([2]), array([523115.83147777]))
>>> from earthkit.geo import nearest_point_kdtree >>> p_ref = [(51.45, 41.49, 12.29), (-0.97, 18.34, -17.1)] >>> p_lat = [44.49, 50.73, 50.1] >>> p_lon = [11.34, 7.90, -8.1] >>> nearest_point_kdtree(p_ref, (p_lat, p_lon)) (array([2, 0, 2]), array([ 523115.83147777, 659558.55282001, 4283987.17429322]))