xugrid.Ugrid1d.sel_points#
- Ugrid1d.sel_points(obj, x: ndarray, y: ndarray, method: str | None = None, out_of_bounds='warn', fill_value=nan, tolerance: float | None = None)#
Select points in the unstructured grid.
For data on the core dimension (faces for Ugrid2d, edges for Ugrid1d), points are located by checking containment unless method is “nearest”. For data on other dimension (e.g. nodes), the nearest entity is found.
- Parameters:
x (1d array of floats with shape
(n_points,))y (1d array of floats with shape
(n_points,))obj (xr.DataArray or xr.Dataset)
method (str, {None, "nearest"}, optional) –
None: default, locate the core entity (face for Ugrid2d, edge for Ugrid1d) that contains each point. For secondary entities (nodes and edges for Ugrid2d; nodes for Ugrid1d), the nearest is always returned.
”nearest”: locate the nearest entity to each point, including the core entity.
out_of_bounds (str, default
"warn") –What to do when points are located outside of any feature:
raise: raise a ValueError.
ignore: return
fill_valuefor the out of bounds points.warn: give a warning and return NaN for the out of bounds points.
drop: drop the out of bounds points. They may be identified via the
indexcoordinate of the returned selection.
fill_value (scalar, DataArray, Dataset, or callable, optional, default: np.nan) – Value to assign to out-of-bounds points if out_of_bounds is warn or ignore. Forwarded to xarray’s
.where()method.tolerance (float, optional) – The tolerance used to determine whether a point is on an edge. This is a floating point precision criterion, thus cannot be directly be interpreted as a distance. If None,
numba_celltreeestimates an appropriate tolerance by multiplying the maximum diagonal of the bounding boxes with 1e-12.
- Returns:
selection – The name of the topology is prefixed in the x, y coordinates and in a points dimension.
- Return type:
xr.DataArray or xr.Dataset