Class: QgsLabelLineSettings

class qgis.core.QgsLabelLineSettings

Bases: sip.wrapper

Contains settings related to how the label engine places and formats labels for line features (or polygon features which are labeled in a “perimeter” style mode).

New in version 3.16:

Enums

AnchorClipping

Bases: enum.IntEnum

AnchorTextPoint

Bases: enum.IntEnum

AnchorType

Bases: enum.IntEnum

DirectionSymbolPlacement

Bases: enum.IntEnum

Methods

addDirectionSymbol

Returns True if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring.

anchorClipping

Returns the line anchor clipping mode, which dictates how line strings are clipped before calculating the line anchor placement.

anchorTextPoint

Returns the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

anchorType

Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

directionSymbolPlacement

Returns the placement for direction symbols.

leftDirectionSymbol

Returns the string to use for left direction arrows.

lineAnchorPercent

Returns the percent along the line at which labels should be placed.

mergeLines

Returns True if connected line features with identical label text should be merged prior to generating label positions.

overrunDistance

Returns the distance which labels are allowed to overrun past the start or end of line features.

overrunDistanceMapUnitScale

Returns the map unit scale for label overrun distance.

overrunDistanceUnit

Returns the units for label overrun distance.

placementFlags

Returns the line placement flags, which dictate how line labels can be placed above or below the lines.

reverseDirectionSymbol

Returns True if direction symbols should be reversed.

rightDirectionSymbol

Returns the string to use for right direction arrows.

setAddDirectionSymbol

Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring.

setAnchorClipping

Sets the line anchor clipping mode, which dictates how line strings are clipped before calculating the line anchor placement.

setAnchorTextPoint

Sets the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

setAnchorType

Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

setDirectionSymbolPlacement

Sets the placement for direction symbols.

setLeftDirectionSymbol

Sets the string to use for left direction arrows.

setLineAnchorPercent

Sets the percent along the line at which labels should be placed.

setMergeLines

Sets whether connected line features with identical label text should be merged prior to generating label positions.

setOverrunDistance

Sets the distance which labels are allowed to overrun past the start or end of line features.

setOverrunDistanceMapUnitScale

Sets the map unit scale for label overrun distance.

setOverrunDistanceUnit

Sets the unit for label overrun distance.

setPlacementFlags

Returns the line placement flags, which dictate how line labels can be placed above or below the lines.

setReverseDirectionSymbol

Sets whether the direction symbols should be reversed.

setRightDirectionSymbol

Sets the string to use for right direction arrows.

updateDataDefinedProperties

Updates the thinning settings to respect any data defined properties set within the specified properties collection.

Attributes

staticMetaObject

class AnchorClipping(value)

Bases: enum.IntEnum

Clipping behavior for line anchor calculation.

New in version 3.20.

  • UseVisiblePartsOfLine: Only visible parts of lines are considered when calculating the line anchor for labels

  • UseEntireLine: Entire original feature line geometry is used when calculating the line anchor for labels

UseEntireLine = 1
UseVisiblePartsOfLine = 0
baseClass

alias of QgsLabelLineSettings

class AnchorTextPoint(value)

Bases: enum.IntEnum

Anchor point of label text.

New in version 3.26.

  • StartOfText: Anchor using start of text

  • CenterOfText: Anchor using center of text

  • EndOfText: Anchor using end of text

  • FollowPlacement: Automatically set the anchor point based on the lineAnchorPercent() value. Values <25% will use the start of text, values > 75% will use the end of text, and values in between will use the center of the text

CenterOfText = 1
EndOfText = 2
FollowPlacement = 3
StartOfText = 0
baseClass

alias of QgsLabelLineSettings

class AnchorType(value)

Bases: enum.IntEnum

Line anchor types

  • HintOnly: Line anchor is a hint for preferred placement only, but other placements close to the hint are permitted

  • Strict: Line anchor is a strict placement, and other placements are not permitted

HintOnly = 0
Strict = 1
baseClass

alias of QgsLabelLineSettings

class DirectionSymbolPlacement(value)

Bases: enum.IntEnum

Placement options for direction symbols.

  • SymbolLeftRight: Place direction symbols on left/right of label

  • SymbolAbove: Place direction symbols on above label

  • SymbolBelow: Place direction symbols on below label

SymbolAbove = 1
SymbolBelow = 2
SymbolLeftRight = 0
baseClass

alias of QgsLabelLineSettings

addDirectionSymbol(self) bool

Returns True if ‘<’ or ‘>’ (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring.

Return type:

bool

anchorClipping(self) QgsLabelLineSettings.AnchorClipping

Returns the line anchor clipping mode, which dictates how line strings are clipped before calculating the line anchor placement.

See also

anchorType()

New in version 3.20.

Return type:

QgsLabelLineSettings.AnchorClipping

anchorTextPoint(self) QgsLabelLineSettings.AnchorTextPoint

Returns the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

New in version 3.26.

Return type:

QgsLabelLineSettings.AnchorTextPoint

anchorType(self) QgsLabelLineSettings.AnchorType

Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

See also

setAnchorType()

See also

anchorClipping()

Return type:

QgsLabelLineSettings.AnchorType

directionSymbolPlacement(self) QgsLabelLineSettings.DirectionSymbolPlacement

Returns the placement for direction symbols.

This setting controls whether to place direction symbols to the left/right, above or below label.

Return type:

QgsLabelLineSettings.DirectionSymbolPlacement

leftDirectionSymbol(self) str

Returns the string to use for left direction arrows.

Return type:

str

lineAnchorPercent(self) float

Returns the percent along the line at which labels should be placed.

By default, this is 0.5 which indicates that labels should be placed as close to the center of the line as possible. A value of 0.0 indicates that the labels should be placed as close to the start of the line as possible, while a value of 1.0 pushes labels towards the end of the line.

See also

anchorType()

See also

anchorClipping()

Return type:

float

mergeLines(self) bool

Returns True if connected line features with identical label text should be merged prior to generating label positions.

See also

setMergeLines()

Return type:

bool

overrunDistance(self) float

Returns the distance which labels are allowed to overrun past the start or end of line features.

Return type:

float

overrunDistanceMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for label overrun distance.

Return type:

QgsMapUnitScale

overrunDistanceUnit(self) QgsUnitTypes.RenderUnit

Returns the units for label overrun distance.

Return type:

QgsUnitTypes.RenderUnit

placementFlags(self) QgsLabeling.LinePlacementFlags

Returns the line placement flags, which dictate how line labels can be placed above or below the lines.

Return type:

QgsLabeling.LinePlacementFlags

reverseDirectionSymbol(self) bool

Returns True if direction symbols should be reversed.

Return type:

bool

rightDirectionSymbol(self) str

Returns the string to use for right direction arrows.

Return type:

str

setAddDirectionSymbol(self, enabled: bool)

Sets whether ‘<’ or ‘>’ (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring.

Parameters:

enabled (bool) –

setAnchorClipping(self, clipping: QgsLabelLineSettings.AnchorClipping)

Sets the line anchor clipping mode, which dictates how line strings are clipped before calculating the line anchor placement.

See also

anchorClipping()

See also

setAnchorType()

New in version 3.20.

Parameters:

clipping (QgsLabelLineSettings.AnchorClipping) –

setAnchorTextPoint(self, point: QgsLabelLineSettings.AnchorTextPoint)

Sets the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

New in version 3.26.

Parameters:

point (QgsLabelLineSettings.AnchorTextPoint) –

setAnchorType(self, type: QgsLabelLineSettings.AnchorType)

Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

See also

anchorType()

Parameters:

type (QgsLabelLineSettings.AnchorType) –

setDirectionSymbolPlacement(self, placement: QgsLabelLineSettings.DirectionSymbolPlacement)

Sets the placement for direction symbols.

This setting controls whether to place direction symbols to the left/right, above or below label.

Parameters:

placement (QgsLabelLineSettings.DirectionSymbolPlacement) –

setLeftDirectionSymbol(self, symbol: str)

Sets the string to use for left direction arrows.

Parameters:

symbol (str) –

setLineAnchorPercent(self, percent: float)

Sets the percent along the line at which labels should be placed.

By default, this is 0.5 which indicates that labels should be placed as close to the center of the line as possible. A value of 0.0 indicates that the labels should be placed as close to the start of the line as possible, while a value of 1.0 pushes labels towards the end of the line.

See also

setAnchorType()

Parameters:

percent (float) –

setMergeLines(self, merge: bool)

Sets whether connected line features with identical label text should be merged prior to generating label positions.

See also

mergeLines()

Parameters:

merge (bool) –

setOverrunDistance(self, distance: float)

Sets the distance which labels are allowed to overrun past the start or end of line features.

Parameters:

distance (float) –

setOverrunDistanceMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for label overrun distance.

Parameters:

scale (QgsMapUnitScale) –

setOverrunDistanceUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for label overrun distance.

Parameters:

unit (QgsUnitTypes.RenderUnit) –

setPlacementFlags(self, flags: QgsLabeling.LinePlacementFlags | QgsLabeling.LinePlacementFlag)

Returns the line placement flags, which dictate how line labels can be placed above or below the lines.

See also

placementFlags()

Parameters:

flags (Union[QgsLabeling.LinePlacementFlags) –

setReverseDirectionSymbol(self, reversed: bool)

Sets whether the direction symbols should be reversed.

Parameters:

reversed (bool) –

setRightDirectionSymbol(self, symbol: str)

Sets the string to use for right direction arrows.

Parameters:

symbol (str) –

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
updateDataDefinedProperties(self, properties: QgsPropertyCollection, context: QgsExpressionContext)

Updates the thinning settings to respect any data defined properties set within the specified properties collection.

Parameters: