Class: QgsAbstractTerrainProvider

Abstract base class for terrain providers.

Added in version 3.26.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: clone(), crs(), equals(), heightAt(), prepare(), readXml(), type(), writeXml()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAbstractTerrainProvider

Subclasses

QgsFlatTerrainProvider

A terrain provider where the terrain is a simple flat surface.

QgsMeshTerrainProvider

A terrain provider that uses the Z values of a mesh layer to build a terrain surface.

QgsRasterDemTerrainProvider

A terrain provider where the terrain source is a raster DEM layer.

class qgis.core.QgsAbstractTerrainProvider[source]

Bases: object

abstract clone(self) QgsAbstractTerrainProvider | None[source]

Creates a clone of the provider and returns the new object.

Ownership is transferred to the caller.

Return type:

Optional[QgsAbstractTerrainProvider]

abstract crs(self) QgsCoordinateReferenceSystem[source]

Returns the native coordinate reference system of the terrain provider.

Return type:

QgsCoordinateReferenceSystem

abstract equals(self, other: QgsAbstractTerrainProvider | None) bool[source]

Returns True if the provider is equal to other.

Parameters:

other (Optional[QgsAbstractTerrainProvider])

Return type:

bool

abstract heightAt(self, x: float, y: float) float[source]

Returns the height at the point (x,y) in the terrain provider’s native crs().

Returns NaN if the height could not be obtained at the specified point.

Parameters:
  • x (float)

  • y (float)

Return type:

float

offset(self) float[source]

Returns the vertical offset value, used for adjusting the heights from the terrain provider.

See also

setOffset()

See also

scale()

Return type:

float

abstract prepare(self)[source]

Called on the main thread prior to accessing the provider from a background thread.

Subclasses must implement suitable logic in order to prepare for thread-safe calculation of terrain heights on background threads.

readCommonProperties(self, element: QDomElement, context: QgsReadWriteContext)[source]

Reads common properties from a DOM element.

Parameters:
abstract readXml(self, element: QDomElement, context: QgsReadWriteContext) bool[source]

Reads the terrain provider state from a DOM element.

See also

writeXml()

Parameters:
Return type:

bool

virtual resolveReferences(self, project: QgsProject | None)[source]

Resolves reference to layers from stored layer ID (if it has not been resolved already)

Parameters:

project (Optional[QgsProject])

scale(self) float[source]

Returns the vertical scale factor, which can be used to exaggerate vertical heights.

See also

setScale()

See also

offset()

Return type:

float

setOffset(self, offset: float)[source]

Returns the vertical offset value, used for adjusting the heights from the terrain provider

See also

offset()

See also

setScale()

Parameters:

offset (float)

setScale(self, scale: float)[source]

Sets the vertical scale factor, which can be used to exaggerate vertical heights.

See also

scale()

See also

setOffset()

Parameters:

scale (float)

abstract type(self) str[source]

Returns the unique type ID string for the provider.

Return type:

str

writeCommonProperties(self, element: QDomElement, context: QgsReadWriteContext)[source]

Writes common properties to a DOM element.

Parameters:
abstract writeXml(self, document: QDomDocument, context: QgsReadWriteContext) QDomElement[source]

Returns a DOM element representing the state of the terrain provider.

See also

readXml()

Parameters:
Return type:

QDomElement