Class: QgsLinearReferencingSymbolLayer

Line symbol layer used for decorating according to linear referencing.

This symbol layer type allows placing text labels at regular intervals along a line (or at positions corresponding to existing vertices). Positions can be calculated using Cartesian distances, or interpolated from z or m values.

Added in version 3.40.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLinearReferencingSymbolLayer

Base classes

QgsLineSymbolLayer

Abstract base class for line symbol layers.

QgsSymbolLayer

Abstract base class for symbol layers.

Methods

averageAngleLength

Returns the length of line over which the line's direction is averaged when calculating individual label angles.

averageAngleMapUnitScale

Returns the map unit scale for the length over which the line's direction is averaged when calculating individual label angles.

averageAngleUnit

Returns the unit for the length over which the line's direction is averaged when calculating individual label angles.

interval

Returns the interval between labels.

labelOffset

Returns the offset between the line and linear referencing labels.

labelOffsetMapUnitScale

Returns the map unit scale used for calculating the offset between the line and linear referencing labels.

labelOffsetUnit

Returns the unit used for the offset between the line and linear referencing labels.

labelSource

Returns the label source, which dictates what quantity to use for the labels shown.

numericFormat

Returns the numeric format used to format the labels for the layer.

placement

Returns the placement mode for the labels.

rotateLabels

Returns True if the labels and symbols are to be rotated to match their line segment orientation.

setAverageAngleLength

Sets the length of line over which the line's direction is averaged when calculating individual label angles.

setAverageAngleMapUnitScale

Sets the map unit scale for the length over which the line's direction is averaged when calculating individual label angles.

setAverageAngleUnit

Sets the unit for the length over which the line's direction is averaged when calculating individual label angles.

setInterval

Sets the interval between labels.

setLabelOffset

Sets the offset between the line and linear referencing labels.

setLabelOffsetMapUnitScale

Sets the map unit scale used for calculating the offset between the line and linear referencing labels.

setLabelOffsetUnit

Sets the unit used for the offset between the line and linear referencing labels.

setLabelSource

Sets the label source, which dictates what quantity to use for the labels shown.

setNumericFormat

Sets the numeric format used to format the labels for the layer.

setPlacement

Sets the placement mode for the labels.

setRotateLabels

Sets whether the labels and symbols should be rotated to match their line segment orientation.

setShowMarker

Sets whether a marker symbol should be shown corresponding to the labeled point on line.

setSkipMultiplesOf

Sets the multiple distance to skip labels for.

setTextFormat

Sets the text format used to render the layer.

showMarker

Returns True if a marker symbol should be shown corresponding to the labeled point on line.

skipMultiplesOf

Returns the multiple distance to skip labels for.

textFormat

Returns the text format used to render the layer.

Static Methods

create

Creates a new QgsLinearReferencingSymbolLayer, using the specified properties.

class qgis.core.QgsLinearReferencingSymbolLayer[source]

Bases: QgsLineSymbolLayer

averageAngleLength(self) float[source]

Returns the length of line over which the line’s direction is averaged when calculating individual label angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are retrieved through averageAngleUnit()

Return type:

float

averageAngleMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the length over which the line’s direction is averaged when calculating individual label angles.

Return type:

QgsMapUnitScale

averageAngleUnit(self) Qgis.RenderUnit[source]

Returns the unit for the length over which the line’s direction is averaged when calculating individual label angles.

Return type:

Qgis.RenderUnit

static create(properties: Dict[str, Any] = {}) QgsSymbolLayer | None[source]

Creates a new QgsLinearReferencingSymbolLayer, using the specified properties.

The caller takes ownership of the returned object.

Parameters:

properties (Dict[str, Any] = {})

Return type:

Optional[QgsSymbolLayer]

interval(self) float[source]

Returns the interval between labels.

Units are always in the original layer CRS units.

See also

setInterval()

Return type:

float

labelOffset(self) QPointF[source]

Returns the offset between the line and linear referencing labels.

The unit for the offset is retrievable via labelOffsetUnit().

See also

setLabelOffset()

Return type:

QPointF

labelOffsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale used for calculating the offset between the line and linear referencing labels.

Return type:

QgsMapUnitScale

labelOffsetUnit(self) Qgis.RenderUnit[source]

Returns the unit used for the offset between the line and linear referencing labels.

See also

labelOffset()

Return type:

Qgis.RenderUnit

labelSource(self) Qgis.LinearReferencingLabelSource[source]

Returns the label source, which dictates what quantity to use for the labels shown.

See also

setLabelSource()

Return type:

Qgis.LinearReferencingLabelSource

numericFormat(self) QgsNumericFormat | None[source]

Returns the numeric format used to format the labels for the layer.

Return type:

Optional[QgsNumericFormat]

placement(self) Qgis.LinearReferencingPlacement[source]

Returns the placement mode for the labels.

See also

setPlacement()

Return type:

Qgis.LinearReferencingPlacement

rotateLabels(self) bool[source]

Returns True if the labels and symbols are to be rotated to match their line segment orientation.

Return type:

bool

setAverageAngleLength(self, length: float)[source]

Sets the length of line over which the line’s direction is averaged when calculating individual label angles. Longer lengths smooth out angles from jagged lines to a greater extent.

Units are set through setAverageAngleUnit()

Parameters:

length (float)

setAverageAngleMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the length over which the line’s direction is averaged when calculating individual label angles.

Parameters:

scale (QgsMapUnitScale)

setAverageAngleUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the length over which the line’s direction is averaged when calculating individual label angles.

Parameters:

unit (Qgis.RenderUnit)

setInterval(self, interval: float)[source]

Sets the interval between labels.

Units are always in the original layer CRS units.

See also

setInterval()

Parameters:

interval (float)

setLabelOffset(self, offset: QPointF | QPoint)[source]

Sets the offset between the line and linear referencing labels.

The unit for the offset is set via setLabelOffsetUnit().

See also

labelOffset()

Parameters:

offset (Union[QPointF, QPoint])

setLabelOffsetMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale used for calculating the offset between the line and linear referencing labels.

Parameters:

scale (QgsMapUnitScale)

setLabelOffsetUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit used for the offset between the line and linear referencing labels.

See also

setLabelOffset()

Parameters:

unit (Qgis.RenderUnit)

setLabelSource(self, source: Qgis.LinearReferencingLabelSource)[source]

Sets the label source, which dictates what quantity to use for the labels shown.

See also

labelSource()

Parameters:

source (Qgis.LinearReferencingLabelSource)

setNumericFormat(self, format: QgsNumericFormat | None)[source]

Sets the numeric format used to format the labels for the layer.

Ownership of format is transferred to the layer.

See also

numericFormat()

Parameters:

format (Optional[QgsNumericFormat])

setPlacement(self, placement: Qgis.LinearReferencingPlacement)[source]

Sets the placement mode for the labels.

See also

placement()

Parameters:

placement (Qgis.LinearReferencingPlacement)

setRotateLabels(self, rotate: bool)[source]

Sets whether the labels and symbols should be rotated to match their line segment orientation.

See also

rotateLabels()

Parameters:

rotate (bool)

setShowMarker(self, show: bool)[source]

Sets whether a marker symbol should be shown corresponding to the labeled point on line.

The marker symbol is set using setSubSymbol()

See also

showMarker()

Parameters:

show (bool)

setSkipMultiplesOf(self, multiple: float)[source]

Sets the multiple distance to skip labels for.

If this value is non-zero, then any labels which are integer multiples of the returned value will be skipped. This allows creation of advanced referencing styles where a single QgsSymbol has multiple QgsLinearReferencingSymbolLayer symbol layers, eg allowing labeling every 100 in a normal font and every 1000 in a bold, larger font.

Parameters:

multiple (float)

setTextFormat(self, format: QgsTextFormat)[source]

Sets the text format used to render the layer.

See also

textFormat()

Parameters:

format (QgsTextFormat)

showMarker(self) bool[source]

Returns True if a marker symbol should be shown corresponding to the labeled point on line.

The marker symbol is set using setSubSymbol()

See also

setShowMarker()

Return type:

bool

skipMultiplesOf(self) float[source]

Returns the multiple distance to skip labels for.

If this value is non-zero, then any labels which are integer multiples of the returned value will be skipped. This allows creation of advanced referencing styles where a single QgsSymbol has multiple QgsLinearReferencingSymbolLayer symbol layers, eg allowing labeling every 100 in a normal font and every 1000 in a bold, larger font.

Return type:

float

textFormat(self) QgsTextFormat[source]

Returns the text format used to render the layer.

See also

setTextFormat()

Return type:

QgsTextFormat