def _mesh_interpolate_worker(coords: npt.NDArray[np.float32], coords_crs: CRS, raster_path: Union[(str, Path)], chunk_size: Optional[int], method: Literal[('spline', 'linear', 'nearest')]='spline', filter_by_shape: bool=False):
    "Interpolator worker function to be used in parallel calls\n\n    Parameters\n    ----------\n    coords : npt.NDArray[np.float32]\n        Mesh node coordinates.\n    coords_crs : CRS\n        Coordinate reference system of the input mesh coordinates.\n    raster_path : str or Path\n        Path to the raster temporary working file.\n    chunk_size : int or None\n        Chunk size for windowing over the raster.\n    method : {'spline', 'linear', 'nearest'}, default='spline'\n        Method of interpolation.\n    filter_by_shape : bool\n        Flag for node filtering based on raster bbox or shape\n\n    Returns\n    -------\n    idxs : npt.NDArray[bool]\n        Mask of the nodes whose values are updated by current\n        interpolation\n    values : npt.NDArray[np.float32]\n        Interpolated values.\n\n    Raises\n    ------\n    ValueError\n        If specified interpolation `method` is not supported.\n    "
    coords = np.array(coords)
    raster = Raster(raster_path)
    idxs = []
    values = []
    for window in raster.iter_windows(chunk_size=chunk_size, overlap=2):
        if (not raster.crs.equals(coords_crs)):
            transformer = Transformer.from_crs(coords_crs, raster.crs, always_xy=True)
            (coords[:, 0], coords[:, 1]) = transformer.transform(coords[:, 0], coords[:, 1])
        xi = raster.get_x(window)
        yi = raster.get_y(window)
        zi = raster.get_values(window=window, masked=True)
        if (not filter_by_shape):
            _idxs = np.logical_and(np.logical_and((np.min(xi) <= coords[:, 0]), (np.max(xi) >= coords[:, 0])), np.logical_and((np.min(yi) <= coords[:, 1]), (np.max(yi) >= coords[:, 1])))
        else:
            shape = raster.get_multipolygon()
            gs_pt = gpd.points_from_xy(coords[:, 0], coords[:, 1])
            _idxs = gs_pt.intersects(shape)
        interp_mask = None
        if (method == 'spline'):
            f = RectBivariateSpline(xi, np.flip(yi), np.flipud(zi).T, kx=3, ky=3, s=0)
            _values = f.ev(coords[(_idxs, 0)], coords[(_idxs, 1)])
        elif (method in ['nearest', 'linear']):
            if np.any(zi.mask):
                m_interp = RegularGridInterpolator((xi, np.flip(yi)), np.flipud(zi.mask).T.astype(bool), method=method)
                interp_mask = (m_interp(coords[_idxs]) > 0)
            f = RegularGridInterpolator((xi, np.flip(yi)), np.flipud(zi).T, method=method)
            _values = f(coords[_idxs])
        else:
            raise ValueError(f'Invalid value method specified <{method}>!')
        if (interp_mask is not None):
            helper = np.ones_like(_values).astype(bool)
            helper[interp_mask] = False
            _idxs[_idxs] = helper
            _values = _values[(~ interp_mask)]
        idxs.append(_idxs)
        values.append(_values)
    return (np.hstack(idxs), np.hstack(values))
Interpolator worker function to be used in parallel calls

Parameters
----------
coords : npt.NDArray[np.float32]
    Mesh node coordinates.
coords_crs : CRS
    Coordinate reference system of the input mesh coordinates.
raster_path : str or Path
    Path to the raster temporary working file.
chunk_size : int or None
    Chunk size for windowing over the raster.
method : {'spline', 'linear', 'nearest'}, default='spline'
    Method of interpolation.
filter_by_shape : bool
    Flag for node filtering based on raster bbox or shape

Returns
-------
idxs : npt.NDArray[bool]
    Mask of the nodes whose values are updated by current
    interpolation
values : npt.NDArray[np.float32]
    Interpolated values.

Raises
------
ValueError
    If specified interpolation `method` is not supported.
def _mesh_interpolate_worker(coords: npt.NDArray[np.float32], coords_crs: CRS, raster_path: Union[(str, Path)], chunk_size: Optional[int], method: Literal[('spline', 'linear', 'nearest')]='spline', filter_by_shape: bool=False):
    "Interpolator worker function to be used in parallel calls\n\n    Parameters\n    ----------\n    coords : npt.NDArray[np.float32]\n        Mesh node coordinates.\n    coords_crs : CRS\n        Coordinate reference system of the input mesh coordinates.\n    raster_path : str or Path\n        Path to the raster temporary working file.\n    chunk_size : int or None\n        Chunk size for windowing over the raster.\n    method : {'spline', 'linear', 'nearest'}, default='spline'\n        Method of interpolation.\n    filter_by_shape : bool\n        Flag for node filtering based on raster bbox or shape\n\n    Returns\n    -------\n    idxs : npt.NDArray[bool]\n        Mask of the nodes whose values are updated by current\n        interpolation\n    values : npt.NDArray[np.float32]\n        Interpolated values.\n\n    Raises\n    ------\n    ValueError\n        If specified interpolation `method` is not supported.\n    "
    coords = np.array(coords)
    raster = Raster(raster_path)
    idxs = []
    values = []
    for window in raster.iter_windows(chunk_size=chunk_size, overlap=2):
        if (not raster.crs.equals(coords_crs)):
            transformer = Transformer.from_crs(coords_crs, raster.crs, always_xy=True)
            (coords[:, 0], coords[:, 1]) = transformer.transform(coords[:, 0], coords[:, 1])
        xi = raster.get_x(window)
        yi = raster.get_y(window)
        zi = raster.get_values(window=window, masked=True)
        if (not filter_by_shape):
            _idxs = np.logical_and(np.logical_and((np.min(xi) <= coords[:, 0]), (np.max(xi) >= coords[:, 0])), np.logical_and((np.min(yi) <= coords[:, 1]), (np.max(yi) >= coords[:, 1])))
        else:
            shape = raster.get_multipolygon()
            gs_pt = gpd.points_from_xy(coords[:, 0], coords[:, 1])
            _idxs = gs_pt.intersects(shape)
        interp_mask = None
        if (method == 'spline'):
            f = RectBivariateSpline(xi, np.flip(yi), np.flipud(zi).T, kx=3, ky=3, s=0)
            _values = f.ev(coords[(_idxs, 0)], coords[(_idxs, 1)])
        elif (method in ['nearest', 'linear']):
            if np.any(zi.mask):
                m_interp = RegularGridInterpolator((xi, np.flip(yi)), np.flipud(zi.mask).T.astype(bool), method=method)
                interp_mask = (m_interp(coords[_idxs]) > 0)
            f = RegularGridInterpolator((xi, np.flip(yi)), np.flipud(zi).T, method=method)
            _values = f(coords[_idxs])
        else:
            raise ValueError(f'Invalid value method specified <{method}>!')
        if (interp_mask is not None):
            helper = np.ones_like(_values).astype(bool)
            helper[interp_mask] = False
            _idxs[_idxs] = helper
            _values = _values[(~ interp_mask)]
        idxs.append(_idxs)
        values.append(_values)
    return (np.hstack(idxs), np.hstack(values))