uxarray.Grid.get_faces_containing_point#
- Grid.get_faces_containing_point(points, return_counts=True)#
Identify which grid faces contain the given point(s).
- Parameters:
points (array_like, shape (N, 2) or (2,) or shape (N, 3) or (3,)) – Query point(s) to locate on the grid. - If last dimension is 2, interpreted as (longitude, latitude) in degrees. - If last dimension is 3, interpreted as Cartesian coordinates on the unit sphere: (x, y, z). You may pass a single point (shape (2,) or (3,)) or multiple points (shape (N, 2) or (N, 3)).
return_counts (bool, default=True) –
If True, returns a tuple (face_indices, counts).
If False, returns a list of per-point lists of face indices (no padding).
- Returns:
If return_counts=True –
- face_indicesnp.ndarray, shape (N, M) or (N, 1)
2D array of face indices. Rows are padded with INT_FILL_VALUE when a point lies on corners of multiple faces. If every queried point falls in exactly one face, the result has shape (N, 1).
- countsnp.ndarray, shape (N,)
Number of valid face indices in each row of face_indices.
If return_counts=False –
- List[List[int]]
Python list of length N, where each element is the list of face indices for that point (no padding, in natural order).
Notes
Most points will lie strictly inside exactly one face; in that case, counts == 1 and face_indices has one column.
Points that lie exactly on a vertex or edge shared by multiple faces return multiple indices in the first counts[i] columns of row i, with any remaining columns filled by INT_FILL_VALUE.
Examples
Query a single spherical point
>>> face_indices, counts = uxgrid.get_faces_containing_point(points=(0.0, 0.0))
Query a single Cartesian point
>>> face_indices, counts = uxgrid.get_faces_containing_point( ... points=[0.0, 0.0, 1.0] ... )
Query multiple points at once
>>> pts = [(0.0, 0.0), (10.0, 20.0)] >>> face_indices, counts = uxgrid.get_faces_containing_point(points=pts)
Return a list of lists
>>> face_indices_list = uxgrid.get_faces_containing_point( ... points=[0.0, 0.0, 1.0], return_counts=False ... )