geost.models.model_utils.sample_along_line#
- geost.models.model_utils.sample_along_line(ds: Dataset | DataArray, line: LineString, dist: int | float = None, nsamples: int = None)[source]#
Sample x and y dims of an Xarray Dataset or DataArray over distance along a Shapely LineString object. Sampling can be done using a specified distance or a specified number of samples that need to be taken along the line.
- Parameters:
ds (xr.Dataset or xr.DataArray) – Dataset or DataArray to sample. Must contain dimensions ‘x’ and ‘y’ that refer to the coordinates.
line (LineString) – shapely.geometry.LineString object to use for sampling.
dist (int, float, optional) – Distance between each sample along the line. Takes equally distant samples from the start of the line untill it reaches the end. The default is None.
nsamples (int, optional) – Number of samples to take along the line between the beginning and the end. The default is None.
- Raises:
ValueError – If both or none of dist and nsamples are specified.
- Returns:
ds_sel – Sampled Dataset or DataArray with dimension ‘dist’ for distance.
- Return type:
xr.Dataset or xr.DataArray