# sec_interp.core.utils.sampling module

sec_interp.core.utils.sampling.sample_elevation_along_line(geometry: qgis.core.QgsGeometry, raster_layer: qgis.core.QgsRasterLayer, band_number: int, distance_area: qgis.core.QgsDistanceArea, reference_point: qgis.core.QgsPointXY | None = None, interval: float | None = None) → list[qgis.core.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 where x is distance along section and y is elevation.

  Return type:

    List[QgsPointXY]

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, line_start, distance_area)

      - line_geom (QgsGeometry): The geometry of the section line.

      - line_start (QgsPointXY): The starting point of the line.

      - distance_area (QgsDistanceArea): Fully configured distance object.

  Return type:

    Tuple

  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:

    Interpolated elevation value.

  Return type:

    float