find_closest_point#
- StructuredGrid.find_closest_point(point: Iterable[float], n=1) int #
Find index of closest point in this mesh to the given point.
If wanting to query many points, use a KDTree with scipy or another library as those implementations will be easier to work with.
See: https://github.com/pyvista/pyvista-support/issues/107
- Parameters
- Returns
int
The index of the point in this mesh that is closest to the given point.
See also
Examples
Find the index of the closest point to
(0, 1, 0)
.>>> import pyvista >>> mesh = pyvista.Sphere() >>> index = mesh.find_closest_point((0, 1, 0)) >>> index 212
Get the coordinate of that point.
>>> mesh.points[index] pyvista_ndarray([-0.05218758, 0.49653167, 0.02706946], dtype=float32)