# sec_interp.core.utils.sampling module

Sampling Utilities Module.

This module provides elevation sampling and profile context preparation tools.

sec_interp.core.utils.sampling.sample_elevation_along_line(geometry: QgsGeometry, raster_layer: QgsRasterLayer, band_number: int, distance_area: QgsDistanceArea, reference_point: QgsPointXY | None = None, interval: float | None = None) → list[QgsPointXY]

  Sample elevation values along a line geometry from a raster layer.

  Densifies the line at raster resolution and samples the elevation at each vertex.

  Parameters:

    - geometry – The line geometry to sample along.

    - raster_layer – The source DEM raster layer.

    - band_number – The raster band index to sample.

    - distance_area – Object for geodesic distance calculations.

    - reference_point – Optional start point for distance measurements.

    - interval – Optional sampling interval. If None, uses raster resolution.

  Returns:

    A list of QgsPointXY objects where x is horizontal distance and y is elevation.

sec_interp.core.utils.sampling.prepare_profile_context(line_lyr: qgis.core.QgsVectorLayer) → tuple[qgis.core.QgsGeometry, qgis.core.QgsPointXY, qgis.core.QgsDistanceArea]

  Prepare a common context for profile calculation operations.

  Parameters:

    line_lyr – The cross-section line vector layer.

  Returns:

    - line_geom: The geometry of the section line.

    - line_start: The starting point of the line.

    - distance_area: Fully configured geodesic distance object.

  Return type:

    A tuple containing

  Raises:

    ValueError – If the input layer is empty or has invalid geometry.

sec_interp.core.utils.sampling.interpolate_elevation(topo_data: list, distance: float) → float

  Interpolate elevation at given distance.

  Parameters:

    - topo_data – List of (distance, elevation) tuples.

    - distance – Distance at which to interpolate elevation.

  Returns:

    The interpolated elevation value.