sec_interp.core.utils.geometry module

Geometry Utilities Facade.

Spatial geometry operations using QGIS native algorithms. This module now serves as a facade for modularized sub-submodules.

sec_interp.core.utils.geometry.create_buffer_geometry(geometry: qgis.core.QgsGeometry, crs: qgis.core.QgsCoordinateReferenceSystem, distance: float, segments: int = 5) qgis.core.QgsGeometry

Create a buffer around a geometry.

Parameters:
  • geometry – Input geometry.

  • crs – Coordinate Reference System of the geometry.

  • distance – Buffer distance in layer units.

  • segments – Number of segments for the buffer approximation.

Returns:

The buffered geometry.

sec_interp.core.utils.geometry.create_memory_layer(layer_name: str, layer_type: str, crs: qgis.core.QgsCoordinateReferenceSystem, fields: list[qgis.core.QgsField]) qgis.core.QgsVectorLayer

Create a temporary memory (scratch) layer.

Parameters:
  • layer_name – Name for the layer.

  • layer_type – QGIS geometry type string (e.g., ‘Point’, ‘LineString’).

  • crs – Coordinate reference system.

  • fields – List of fields for the layer.

Returns:

The created memory layer.

sec_interp.core.utils.geometry.densify_line_by_interval(geometry: qgis.core.QgsGeometry, interval: float) qgis.core.QgsGeometry

Densify a line geometry by a specific distance interval.

Adds intermediate vertices to ensure segments are no longer than the interval.

Parameters:
  • geometry – Line geometry to densify.

  • interval – Maximum distance between vertices (in CRS units).

Returns:

The densified QgsGeometry.

sec_interp.core.utils.geometry.extract_all_vertices(geometry: qgis.core.QgsGeometry) list[qgis.core.QgsPointXY]

Extract all vertices from any QGIS geometry type.

Parameters:

geometry – The input QGIS geometry.

Returns:

A flat list of all vertices found in the geometry.

sec_interp.core.utils.geometry.filter_features_by_buffer(features_layer: QgsVectorLayer, buffer_geometry: QgsGeometry, buffer_crs: QgsCoordinateReferenceSystem | None = None) list[QgsFeature]

Filter features that intersect with buffer using spatial index.

Parameters:
  • features_layer – Layer containing features to filter.

  • buffer_geometry – Buffer geometry to use for spatial filter.

  • buffer_crs – CRS of the buffer geometry (optional).

Returns:

List of QgsFeature objects that intersect the query buffer.

sec_interp.core.utils.geometry.get_line_vertices(geometry: qgis.core.QgsGeometry) list[qgis.core.QgsPointXY]

Extract vertices specifically from a line or multiline geometry.

Parameters:

geometry – A QGIS geometry of type LineGeometry.

Returns:

A flat list of vertices.

Raises:

ValueError – If the geometry is null, not a line, or contains no vertices.

sec_interp.core.utils.geometry.run_geometry_operation(operation: str, *args, **kwargs) Any

Wrap generic geometry operations.

Parameters:
  • operation – Name of the operation to perform.

  • *args – Positional arguments for the operation.

  • **kwargs – Keyword arguments for the operation.

Returns:

Result of the operation.