# sec_interp.core.utils.spatial module

Spatial Utilities Module.

Distance calculations, azimuth, and basic spatial operations.

sec_interp.core.utils.spatial.calculate_line_azimuth(line_geom: qgis.core.QgsGeometry) → float

  Calculate the azimuth (compass bearing) of a line geometry.

  Calculates the azimuth based on the first two vertices of the line. Returns 0 for points or single-vertex lines.

  Parameters:

    line_geom – The QGIS line geometry.

  Returns:

    Azimuth in degrees (0-360).

sec_interp.core.utils.spatial.calculate_step_size(geom: qgis.core.QgsGeometry, raster_lyr) → float

  Calculate step size based on slope and raster resolution.

  Deprecated since version Use: densify_line_by_interval() instead for better precision and simpler code. This function is kept for backward compatibility but may be removed in future versions.

  Ensures that sampling occurs at approximately one pixel intervals, accounting for the slope of the line relative to the raster grid.

  Parameters:

    - geom – The geometry to sample along.

    - raster_lyr – The raster layer being sampled.

  Returns:

    Calculated step size in map units.

sec_interp.core.utils.spatial.get_line_start_point(geometry: qgis.core.QgsGeometry) → qgis.core.QgsPointXY

  Get the start point of a line geometry.

  Handles both singlepart and multipart line geometries.

  Parameters:

    geometry – The line geometry.

  Returns:

    The first vertex of the first part of the geometry.

sec_interp.core.utils.spatial.create_distance_area(crs: qgis.core.QgsCoordinateReferenceSystem) → qgis.core.QgsDistanceArea

  Create and configure a QgsDistanceArea object.

  Configures the distance area with the provided CRS, project transform context, and associated ellipsoid for geodesic calculations.

  Parameters:

    crs – The Coordinate Reference System to use.

  Returns:

    The configured distance calculation object.