Class: QgsElevationProfileCanvas

A canvas for elevation profiles.

Added in version 3.26.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsElevationProfileCanvas

Base classes

QgsPlotCanvas

Plot canvas is a class for displaying interactive 2d charts and plots.

QGraphicsView

QAbstractScrollArea

QFrame

QWidget

QObject

QPaintDevice

class qgis.gui.QgsElevationProfileCanvas[source]

Bases: QgsPlotCanvas

__init__(parent: QWidget | None = None)

Constructor for QgsElevationProfileCanvas, with the specified parent widget.

Parameters:

parent (Optional[QWidget] = None)

signal activeJobCountChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

axisScaleRatio(self) float[source]

Returns the current ratio of horizontal (distance) to vertical (elevation) scale for the plot.

Added in version 4.0.

Return type:

float

signal canvasPointHovered[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

canvasPointToPlotPoint(self, point: QPointF | QPoint) QgsProfilePoint[source]

Converts a canvas point to the equivalent plot point.

Parameters:

point (Union[QPointF, QPoint])

Return type:

QgsProfilePoint

clear(self)[source]

Clears the current profile.

distanceUnit(self) Qgis.DistanceUnit[source]

Returns the distance unit used by the canvas.

Added in version 3.32.

Return type:

Qgis.DistanceUnit

identify(self, point: QPointF | QPoint) List[QgsProfileIdentifyResults]

Identify results visible at the specified plot point.

identify(self, rect: QRectF) -> List[QgsProfileIdentifyResults] Identify results visible within the specified plot rect.

Parameters:

point (Union[QPointF, QPoint])

Return type:

List[QgsProfileIdentifyResults]

invalidateCurrentPlotExtent(self)[source]

Invalidates the current plot extent, which means that the visible plot area will be recalculated and “zoom full” operation occur when the next profile generation completes.

layers(self) List[QgsMapLayer]

Returns the list of layers included in the profile.

See also

setLayers()

Return type:

List[QgsMapLayer]

lockAxisScales(self) bool[source]

Returns True if the distance and elevation scales are locked to each other.

Added in version 3.32.

Return type:

bool

plotArea(self) QRectF[source]

Returns the interior rectangle representing the surface of the plot, in canvas coordinates.

Return type:

QRectF

plotPointToCanvasPoint(self, point: QgsProfilePoint) QgsPointXY[source]

Converts a plot point to the equivalent canvas point.

Parameters:

point (QgsProfilePoint)

Return type:

QgsPointXY

profileCurve(self) QgsCurve | None[source]

Returns the profile curve.

The CRS associated with the curve is retrieved via crs().

Return type:

Optional[QgsCurve]

virtual refresh(self)[source]

Triggers a complete regeneration of the profile, causing the profile extraction to perform in the background.

render(self, context: QgsRenderContext, width: float, height: float, plotSettings: Qgs2DXyPlot)[source]

Renders a portion of the profile using the specified render context.

Parameters:
signal scaleChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

virtual scalePlot(self, factor: float)[source]

Scales the plot axis by the given factors.

Parameters:
  • xFactor (float)

  • yFactor (float)

setAxisScaleRatio(self, scale: float)[source]

Sets the ratio of horizontal (distance) to vertical (elevation) scale for the plot.

E.g. a scale of 3 indicates a ratio of 3:1 for distance vs elevation, whereas a scale of 0.3333 indicates a ratio of 1:3 for distance vs elevation.

This will immediately update the visible plot area to match the specified scale.

See also

axisScaleRatio()

Added in version 4.0.

Parameters:

scale (float)

setBackgroundColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the background color to use for the profile canvas.

The chart text, border and axis color will be automatically updated to ensure readability with the new background color.

Added in version 3.34.

Parameters:

color (Union[QColor, Qt.GlobalColor])

setCrs(self, crs: QgsCoordinateReferenceSystem)[source]

Sets the crs associated with the canvas’ map coordinates.

See also

crs()

Parameters:

crs (QgsCoordinateReferenceSystem)

setDistanceUnit(self, unit: Qgis.DistanceUnit)[source]

Sets the distance unit used by the canvas.

See also

distanceUnit()

Added in version 3.32.

Parameters:

unit (Qgis.DistanceUnit)

setLayers(self, layers: Iterable[QgsMapLayer])[source]

Sets the list of layers to include in the profile.

See also

layers()

Parameters:

layers (Iterable[QgsMapLayer])

setLockAxisScales(self, lock: bool)[source]

Sets whether the distance and elevation scales are locked to each other.

See also

lockAxisScales()

Added in version 3.32.

Parameters:

lock (bool)

setProfileCurve(self, curve: QgsCurve | None)[source]

Sets the profile curve.

The CRS associated with curve is set via setCrs().

Ownership is transferred to the plot canvas.

See also

profileCurve()

Parameters:

curve (Optional[QgsCurve])

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

Sets the project associated with the profile.

This must be set before any layers which utilize terrain based elevation settings can be included in the canvas.

Parameters:

project (Optional[QgsProject])

setSnappingEnabled(self, enabled: bool)[source]

Sets whether snapping of cursor points is enabled.

Parameters:

enabled (bool)

setSources(self, sources: Iterable[QgsAbstractProfileSource])[source]

Sets the list of sources to include in the profile.

See also

sources()

Parameters:

sources (Iterable[QgsAbstractProfileSource])

setSubsectionsSymbol(self, symbol: QgsLineSymbol | None)[source]

Sets the symbol used to draw the subsections. If symbol is None, the subsections are not drawn. Ownership of symbol is transferred.

Added in version 3.44.

Parameters:

symbol (Optional[QgsLineSymbol])

setTolerance(self, tolerance: float)[source]

Sets the profile tolerance (in crs() units).

This value determines how far from the profileCurve() is appropriate for inclusion of results. For instance, when a profile is generated for a point vector layer this tolerance distance will dictate how far from the actual profile curve a point can reside within to be included in the results.

See also

tolerance()

Parameters:

tolerance (float)

setVisiblePlotRange(self, minimumDistance: float, maximumDistance: float, minimumElevation: float, maximumElevation: float)[source]

Sets the visible area of the plot.

Parameters:
  • minimumDistance (float)

  • maximumDistance (float)

  • minimumElevation (float)

  • maximumElevation (float)

sources(self) List[QgsAbstractProfileSource]

Returns the list of sources included in the profile.

It includes both layer profile sources and custom sources from the profile source registry.

See also

setSources()

Return type:

List[QgsAbstractProfileSource]

subsectionsSymbol(self) QgsLineSymbol | None[source]

Returns the symbol used to draw the subsections.

Added in version 3.44.

Return type:

Optional[QgsLineSymbol]

tolerance(self) float[source]

Returns the tolerance of the profile (in crs() units).

This value determines how far from the profileCurve() is appropriate for inclusion of results. For instance, when a profile is generated for a point vector layer this tolerance distance will dictate how far from the actual profile curve a point can reside within to be included in the results.

See also

setTolerance()

Return type:

float

visibleDistanceRange(self) QgsDoubleRange[source]

Returns the distance range currently visible in the plot.

Return type:

QgsDoubleRange

visibleElevationRange(self) QgsDoubleRange[source]

Returns the elevation range currently visible in the plot.

Return type:

QgsDoubleRange

zoomFull(self)[source]

Zooms to the full extent of the profile.