xugrid.snap_nodes#
- xugrid.snap_nodes(x: ndarray, y: ndarray, max_snap_distance: float) Tuple[ndarray, ndarray, ndarray] [source]#
Snap neigbhoring vertices together that are located within a maximum snapping distance from each other.
If vertices are located within a maximum distance, some of them are snapped to their neighbors (“targets”), thereby guaranteeing a minimum distance between nodes in the result. The determination of whether a point becomes a target itself or gets snapped to another point is primarily based on the order in which points are processed and their spatial relationships.
This function also return an inverse index array. In case of a connectivity array,
inverse
can be used to index into, yielding the updated numbers. E.g.:updated_face_nodes = inverse[face_nodes]
- Parameters:
x (1D nd array of floats of size N)
y (1D nd array of floats of size N)
max_snap_distance (float)
- Returns:
inverse (1D nd array of ints of size N) – Inverse index array: the new vertex number for every old vertex. Is None when no vertices within max_distance of each other.
x_snapped (1D nd array of floats of size M) – Returns a copy of
x
when no vertices within max_distance of each other.y_snapped (1D nd array of floats of size M) – Returns a copy of
y
when no vertices within max_distance of each other.