gemgis.utils.get_nearest_neighbor
gemgis.utils.get_nearest_neighbor#
- gemgis.utils.get_nearest_neighbor(x: numpy.ndarray, y: numpy.ndarray) numpy.int64 #
Function to return the index of the nearest neighbor for a given point Y
- Parameters
x (np.ndarray) – Array with coordinates of a set of points, e.g.
x=np.array([(0,0), (10,10)])
y (np.ndarray) – Array with coordinates for point y, e.g.
y=np.array([2,2])
- Returns
index – Index of the nearest neighbor of point set X to point Y
- Return type
np.int64
New in version 1.0.x.
Example
>>> import gemgis as gg >>> import numpy as np >>> x = np.array([(0,0), (10,10)]) >>> x array([[ 0, 0], [10, 10]])
>>> y = np.array([2,2]) >>> y array([2, 2])
>>> index = gg.utils.get_nearest_neighbor(x=x, y=y) >>> index 0
See also
calculate_number_of_isopoints
Calculating the number of isopoints that are necessary to interpolate lines