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

Methods

axisScaleRatio

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

canvasPointToPlotPoint

Converts a canvas point to the equivalent plot point.

clear

Clears the current profile.

distanceUnit

Returns the distance unit used by the canvas.

identify

Identify results visible at the specified plot point.

invalidateCurrentPlotExtent

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

Returns the list of layers included in the profile.

lockAxisScales

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

plotArea

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

plotPointToCanvasPoint

Converts a plot point to the equivalent canvas point.

profileCurve

Returns the profile curve.

render

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

setAxisScaleRatio

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

setBackgroundColor

Sets the background color to use for the profile canvas.

setCrs

Sets the crs associated with the canvas' map coordinates.

setDistanceUnit

Sets the distance unit used by the canvas.

setLayers

Sets the list of layers to include in the profile.

setLockAxisScales

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

setProfileCurve

Sets the profile curve.

setProject

Sets the project associated with the profile.

setSnappingEnabled

Sets whether snapping of cursor points is enabled.

setSubsectionsSymbol

Sets the symbol used to draw the subsections.

setTolerance

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

setVisiblePlotRange

Sets the visible area of the plot.

subsectionsSymbol

Returns the symbol used to draw the subsections.

tolerance

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

visibleDistanceRange

Returns the distance range currently visible in the plot.

visibleElevationRange

Returns the elevation range currently visible in the plot.

zoomFull

Zooms to the full extent of the profile.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsElevationProfileCanvas. See the FAQ for more details.

refresh

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

scalePlot

Signals

activeJobCountChanged

Emitted when the number of active background jobs changes.

canvasPointHovered

Emitted when the mouse hovers over the specified point (in canvas coordinates).

scaleChanged

Emitted when the plot scale is changed.

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(count: int)[source]

Emitted when the number of active background jobs changes.

Parameters:

count (int)

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(point: QgsPointXY, profilePoint: QgsProfilePoint)[source]

Emitted when the mouse hovers over the specified point (in canvas coordinates).

The profilePoint argument gives the hovered profile point, which may be snapped.

Parameters:
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.

Parameters:

point (Union[QPointF, QPoint])

Return type:

List[QgsProfileIdentifyResults]

identify(self, rect: QRectF) List[QgsProfileIdentifyResults]

Identify results visible within the specified plot rect.

Parameters:

rect (QRectF)

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]

Emitted when the plot scale is changed.

Added in version 4.0.

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

factor (float)

virtual scalePlot(self, xFactor: float, yFactor: 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)

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)

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.