Class: QgsLabelPosition

Represents the calculated placement of a map label.

Attributes

cornerPoints

featureId

ID of feature associated with this label.

groupedLabelId

If non zero, indicates that the label position is part of a group of label positions (i.e. a character in a curved label).

height

Heeght of label bounding box, in map units.

isDiagram

True if label is a diagram.

isPinned

True if label position has been pinned.

isUnplaced

True if label position corresponds to an unplaced label.

labelFont

Font which the label is rendered using.

labelGeometry

A polygon geometry representing the label's bounds in map coordinates.

labelRect

labelText

String shown in label.

layerID

ID of associated map layer.

providerID

ID of the associated label provider.

rotation

Rotation of label, in degrees clockwise.

upsideDown

True if label is upside down.

width

Width of label bounding box, in map units.

class qgis.core.QgsLabelPosition[source]

Bases: object

__init__(id: int, r: float, corners: Iterable[QgsPointXY], rect: QgsRectangle, w: float, h: float, layer: str | None, labeltext: str | None, labelfont: QFont, upside_down: bool, diagram: bool = False, pinned: bool = False, providerId: str | None = '', labelGeometry: QgsGeometry = QgsGeometry(), isUnplaced: bool = False)

Constructor for QgsLabelPosition.

Parameters:
  • id (int) – associated feature ID

  • r (float) – label rotation in degrees clockwise

  • corners (Iterable[QgsPointXY]) – corner points of label bounding box, in map units

  • rect (QgsRectangle) – label bounding box, in map units

  • w (float) – width of label, in map units

  • h (float) – height of label, in map units

  • layer (Optional[str]) – ID of associated map layer

  • labeltext (Optional[str]) – text rendered for label

  • labelfont (QFont) – font used to render label

  • upside_down (bool) – True if label is upside down

  • diagram (bool = False) – True if label is a diagram

  • pinned (bool = False) – True if label has pinned placement

  • providerId (Optional[str] = '') – ID of associated label provider

  • labelGeometry (QgsGeometry = QgsGeometry()) – polygon geometry of label boundary

  • isUnplaced (bool = False) – set to True if label was unplaced (e.g. due to collisions with other labels)

__init__()
__init__(a0: QgsLabelPosition)
Parameters:

a0 (QgsLabelPosition)

cornerPoints
featureId: QgsFeatureId

ID of feature associated with this label.

groupedLabelId: int

If non zero, indicates that the label position is part of a group of label positions (i.e. a character in a curved label).

All other linked positions will share the same groupedLabelId.

height: float

Heeght of label bounding box, in map units.

isDiagram: bool

True if label is a diagram.

isPinned: bool

True if label position has been pinned.

isUnplaced: bool

True if label position corresponds to an unplaced label.

Added in version 3.10.

labelFont: QFont

Font which the label is rendered using.

labelGeometry: QgsGeometry

A polygon geometry representing the label’s bounds in map coordinates.

Added in version 3.4.9.

labelRect
labelText: str

String shown in label.

layerID: str

ID of associated map layer.

providerID: str

ID of the associated label provider.

rotation: float

Rotation of label, in degrees clockwise.

upsideDown: bool

True if label is upside down.

width: float

Width of label bounding box, in map units.