Class: QgsMarkerSymbolLayer

Abstract base class for marker symbol layers.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: bounds(), QgsSymbolLayer.clone(), QgsSymbolLayer.layerType(), QgsSymbolLayer.properties(), renderPoint()

Class Hierarchy

Inheritance diagram of qgis.core.QgsMarkerSymbolLayer

Base classes

QgsSymbolLayer

Abstract base class for symbol layers.

Subclasses

QgsRasterMarkerSymbolLayer

Raster marker symbol layer class.

QgsEllipseSymbolLayer

A symbol layer for rendering objects with major and minor axis (e.g. ellipse, rectangle, etc).

QgsSimpleMarkerSymbolLayerBase

Abstract base class for simple marker symbol layers.

QgsFontMarkerSymbolLayer

A marker symbol layer which displays characters rendered using a font.

QgsMaskMarkerSymbolLayer

Special symbol layer that uses its sub symbol as a selective mask.

QgsSvgMarkerSymbolLayer

A marker symbol layer which renders an SVG graphic.

QgsVectorFieldSymbolLayer

A symbol layer class for displaying displacement arrows based on point layer attributes.

Enums

HorizontalAnchorPoint

Marker symbol horizontal anchor points.

VerticalAnchorPoint

Marker symbol vertical anchor points.

Abstract Methods

bounds

Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.

renderPoint

Renders a marker at the specified point.

Methods

angle

Returns the rotation angle for the marker, in degrees clockwise from north.

horizontalAnchorPoint

Returns the horizontal anchor point for positioning the symbol.

markerOffset

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

markerOffset2

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

markerOffsetWithWidthAndHeight

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

offset

Returns the marker's offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature's geometry.

offsetMapUnitScale

Returns the map unit scale for the symbol's offset.

offsetUnit

Returns the units for the symbol's offset.

scaleMethod

Returns the method to use for scaling the marker's size.

setAngle

Sets the rotation angle for the marker.

setHorizontalAnchorPoint

Sets the horizontal anchor point for positioning the symbol.

setLineAngle

Sets the line angle modification for the symbol's angle.

setOffset

Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature's geometry.

setOffsetMapUnitScale

Sets the map unit scale for the symbol's offset.

setOffsetUnit

Sets the units for the symbol's offset.

setScaleMethod

Sets the method to use for scaling the marker's size.

setSizeMapUnitScale

Sets the map unit scale for the symbol's size.

setSizeUnit

Sets the units for the symbol's size.

setVerticalAnchorPoint

Sets the vertical anchor point for positioning the symbol.

size

Returns the symbol size.

sizeMapUnitScale

Returns the map unit scale for the symbol's size.

sizeUnit

Returns the units for the symbol's size.

verticalAnchorPoint

Returns the vertical anchor point for positioning the symbol.

Virtual Methods

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

setSize

Sets the symbol size.

writeSldMarker

Writes the symbol layer definition as a SLD XML element.

class qgis.core.QgsMarkerSymbolLayer[source]

Bases: QgsSymbolLayer

__init__(locked: bool = False)

Constructor for QgsMarkerSymbolLayer.

Parameters:

locked (bool = False) – set to True to lock symbol color

class HorizontalAnchorPoint(*values)

Bases: IntEnum

Marker symbol horizontal anchor points.

Note

Prior to QGIS 3.44 this was available as QgsMarkerSymbolLayer.HorizontalAnchorPoint

Added in version 3.44.

  • Left: Align to left side of symbol

  • Center: Align to horizontal center of symbol

    Available as QgsMarkerSymbolLayer.HCenter in older QGIS releases.

  • Right: Align to right side of symbol

class VerticalAnchorPoint(*values)

Bases: IntEnum

Marker symbol vertical anchor points.

Note

Prior to QGIS 3.44 this was available as QgsMarkerSymbolLayer.VerticalAnchorPoint

Added in version 3.44.

  • Top: Align to top of symbol

  • Center: Align to vertical center of symbol

    Available as QgsMarkerSymbolLayer.VCenter in older QGIS releases.

  • Bottom: Align to bottom of symbol

  • Baseline: Align to baseline of symbol, e.g. font baseline for font marker symbol layers. Treated as Bottom if no baseline is available for the symbol layer type.

    Added in version 3.44.

angle(self) float[source]

Returns the rotation angle for the marker, in degrees clockwise from north.

See also

setAngle()

Return type:

float

abstract bounds(self, point: QPointF | QPoint, context: QgsSymbolRenderContext) QRectF[source]

Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.

Return type:

QRectF

Returns:

approximate symbol bounds, in painter units

Parameters:
horizontalAnchorPoint(self) Qgis.HorizontalAnchorPoint[source]

Returns the horizontal anchor point for positioning the symbol. The symbol will be drawn so that the horizontal anchor point is aligned with the marker’s desired location.

Return type:

Qgis.HorizontalAnchorPoint

markerOffset(self, context: QgsSymbolRenderContext)[source]

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context (QgsSymbolRenderContext) -> (float) – symbol render context

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

markerOffset2(self, context: QgsSymbolRenderContext, width: float, height: float, widthUnit: Qgis.RenderUnit, heightUnit: Qgis.RenderUnit, widthMapUnitScale: QgsMapUnitScale, heightMapUnitScale: QgsMapUnitScale)

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • width (float) – marker width

  • height (float) – marker height

  • widthUnit (Qgis.RenderUnit) – unit for marker width

  • heightUnit (Qgis.RenderUnit) – unit for marker height

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

  • widthMapUnitScale (QgsMapUnitScale) – map unit scale for marker width

  • heightMapUnitScale (QgsMapUnitScale) -> (float) – map unit scale for marker height

markerOffsetWithWidthAndHeight(self, context: QgsSymbolRenderContext, width: float, height: float)

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • width (float) – marker width

  • height (float) -> (float) – marker height

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

offset(self) QPointF[source]

Returns the marker’s offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature’s geometry. Units are specified by offsetUnit().

See also

setOffset()

See also

offsetUnit()

Return type:

QPointF

offsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the symbol’s offset.

See also

offset()

See also

offsetUnit()

Return type:

QgsMapUnitScale

offsetUnit(self) Qgis.RenderUnit[source]

Returns the units for the symbol’s offset.

See also

setOffsetUnit()

See also

offset()

Return type:

Qgis.RenderUnit

abstract renderPoint(self, point: QPointF | QPoint, context: QgsSymbolRenderContext)[source]

Renders a marker at the specified point. Derived classes must implement this to handle drawing the point.

Parameters:
  • point (Union[QPointF, QPoint]) – position at which to render point, in painter units

  • context (QgsSymbolRenderContext) – symbol render context

scaleMethod(self) Qgis.ScaleMethod[source]

Returns the method to use for scaling the marker’s size.

See also

setScaleMethod()

Return type:

Qgis.ScaleMethod

setAngle(self, angle: float)[source]

Sets the rotation angle for the marker.

Parameters:

angle (float) – angle in degrees clockwise from north.

See also

angle()

See also

setLineAngle()

setHorizontalAnchorPoint(self, h: Qgis.HorizontalAnchorPoint)[source]

Sets the horizontal anchor point for positioning the symbol.

Parameters:

h (Qgis.HorizontalAnchorPoint) – anchor point. Symbol will be drawn so that the horizontal anchor point is aligned with the marker’s desired location.

setLineAngle(self, lineAngle: float)[source]

Sets the line angle modification for the symbol’s angle. This angle is added to the marker’s rotation and data defined rotation before rendering the symbol, and is usually used for orienting symbols to match a line’s angle.

Parameters:

lineAngle (float) – Angle in degrees clockwise from north, valid values are between 0 and 360

See also

setAngle()

See also

angle()

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

Sets the marker’s offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature’s geometry.

Parameters:

offset (Union[QPointF, QPoint]) – marker offset. Units are specified by offsetUnit()

See also

offset()

See also

setOffsetUnit()

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the symbol’s offset.

Parameters:

scale (QgsMapUnitScale) – offset map unit scale

See also

setOffset()

See also

setOffsetUnit()

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

Sets the units for the symbol’s offset.

Parameters:

unit (Qgis.RenderUnit) – offset units

See also

offsetUnit()

See also

setOffset()

setScaleMethod(self, scaleMethod: Qgis.ScaleMethod)[source]

Sets the method to use for scaling the marker’s size.

Parameters:

scaleMethod (Qgis.ScaleMethod) – scale method

See also

scaleMethod()

virtual setSize(self, size: float)[source]

Sets the symbol size.

Parameters:

size (float) – symbol size. Units are specified by sizeUnit().

See also

size()

See also

setSizeUnit()

setSizeMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the symbol’s size.

Parameters:

scale (QgsMapUnitScale) – size map unit scale

See also

setSize()

See also

setSizeUnit()

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

Sets the units for the symbol’s size.

Parameters:

unit (Qgis.RenderUnit) – size units

See also

sizeUnit()

See also

setSize()

setVerticalAnchorPoint(self, v: Qgis.VerticalAnchorPoint)[source]

Sets the vertical anchor point for positioning the symbol.

Parameters:

v (Qgis.VerticalAnchorPoint) – anchor point. Symbol will be drawn so that the vertical anchor point is aligned with the marker’s desired location.

size(self) float[source]

Returns the symbol size. Units are specified by sizeUnit().

See also

setSize()

See also

sizeUnit()

Return type:

float

sizeMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the symbol’s size.

See also

size()

See also

sizeUnit()

Return type:

QgsMapUnitScale

sizeUnit(self) Qgis.RenderUnit[source]

Returns the units for the symbol’s size.

See also

setSizeUnit()

See also

size()

Return type:

Qgis.RenderUnit

verticalAnchorPoint(self) Qgis.VerticalAnchorPoint[source]

Returns the vertical anchor point for positioning the symbol. The symbol will be drawn so that the vertical anchor point is aligned with the marker’s desired location.

Return type:

Qgis.VerticalAnchorPoint

virtual writeSldMarker(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])[source]

Writes the symbol layer definition as a SLD XML element.

Parameters:
  • doc (QDomDocument) – XML document

  • element (QDomElement) – parent XML element

  • props (Dict[str, Any]) – symbol layer definition (see properties())

Deprecated since version 3.44: Use the version with QgsSldExportContext instead.

virtual writeSldMarker(self, doc: QDomDocument, element: QDomElement, context: QgsSldExportContext) bool[source]

Writes the symbol layer definition as a SLD XML element.

Parameters:
  • doc (QDomDocument) – XML document

  • element (QDomElement) – parent XML element

  • context (QgsSldExportContext) – export context

Added in version 3.44.

Return type:

bool