Class: QgsMarkerSymbol

class qgis.core.QgsMarkerSymbol(layers: Iterable[QgsSymbolLayer] = [])

Bases: QgsSymbol

Constructor for QgsMarkerSymbol, with the specified list of initial symbol layers.

Ownership of the layers are transferred to the symbol.

A marker symbol type, for rendering Point and MultiPoint geometries.

Parameters

layers

angle(self) → float

Returns the marker angle for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the angle of the first symbol layer.

See also

setAngle()

New in version 2.16.

Return type

float

bounds(self, point: Union[QPointF, QPoint], context: QgsRenderContext, feature: QgsFeature = QgsFeature()) → QRectF

Returns the approximate bounding box of the marker symbol, which includes the bounding box of all symbol layers for the symbol. It is recommended to use this method only between startRender() and stopRender() calls, or data defined rotation and offset will not be correctly calculated.

Parameters
  • point (Union[QPointF) – location of rendered point in painter units

  • context (QgsRenderContext) – render context

  • feature (QgsFeature = QgsFeature()) – feature being rendered at point (optional). If not specified, the bounds calculation will not include data defined parameters such as offset and rotation

Return type

QRectF

Returns

approximate symbol bounds, in painter units

New in version 2.14.

clone(self) → QgsMarkerSymbol
Return type

QgsMarkerSymbol

cloneLayers()
createSimple(properties: Dict[str, str]) → QgsMarkerSymbol

Create a marker symbol with one symbol layer: SimpleMarker with specified properties. This is a convenience method for easier creation of marker symbols.

Parameters

properties (Dict[str) –

Return type

QgsMarkerSymbol

dataDefinedAngle(self) → QgsProperty

Returns data defined angle for whole symbol (including all symbol layers).

Return type

QgsProperty

Returns

data defined angle, or invalid property if angle is not set at the marker level.

New in version 3.0.

dataDefinedSize(self) → QgsProperty

Returns data defined size for whole symbol (including all symbol layers).

Return type

QgsProperty

Returns

data defined size, or invalid property if size is not set at the marker level.

New in version 3.0.

renderPoint(self, point: Union[QPointF, QPoint], f: QgsFeature, context: QgsRenderContext, layer: int = -1, selected: bool = False)

Renders the symbol at the specified point, using the given render context.

The f argument is used to pass the feature currently being rendered (when available).

If only a single symbol layer from the symbol should be rendered, it should be specified in the layer argument. A layer of -1 indicates that all symbol layers should be rendered.

If selected is true then the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.

Parameters
renderUsingLayer()
renderVertexMarker()
scaleMethod(self) → QgsSymbol.ScaleMethod
Return type

QgsSymbol.ScaleMethod

setAngle(self, symbolAngle: float)

Sets the angle for the whole symbol. Individual symbol layer sizes will be rotated to maintain their current relative angle to the whole symbol angle.

Parameters

symbolAngle (float) – new symbol angle

See also

angle()

setDataDefinedAngle(self, property: QgsProperty)

Set data defined angle for whole symbol (including all symbol layers).

New in version 3.0.

Parameters

property (QgsProperty) –

setDataDefinedSize(self, property: QgsProperty)

Set data defined size for whole symbol (including all symbol layers).

New in version 3.0.

Parameters

property (QgsProperty) –

setLineAngle(self, lineAngle: float)

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, valid values are between 0 and 360

New in version 2.9.

setScaleMethod(self, scaleMethod: QgsSymbol.ScaleMethod)
Parameters

scaleMethod (QgsSymbol.ScaleMethod) –

setSize(self, size: float)

Sets the size for the whole symbol. Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.

Parameters

size (float) – new symbol size

See also

size()

See also

setSizeUnit()

setSizeMapUnitScale(self, scale: QgsMapUnitScale)

Sets the size map unit scale for the whole symbol (including all symbol layers).

Parameters

scale (QgsMapUnitScale) – map unit scale

See also

setSizeUnit()

See also

setSize()

New in version 2.16.

setSizeUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the size units for the whole symbol (including all symbol layers).

Parameters

unit (QgsUnitTypes.RenderUnit) – size units

See also

sizeUnit()

See also

setSize()

New in version 2.16.

size(self) → float

Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layers in the symbol.

Warning

This returned value is inaccurate if the symbol consists of multiple symbol layers with different size units. Use the overload accepting a QgsRenderContext argument instead for accurate sizes in this case.

See also

setSize()

See also

sizeUnit()

size(self, context: QgsRenderContext) -> float Returns the symbol size, in painter units. This is the maximum size of all marker symbol layers in the symbol.

This method returns an accurate size by calculating the actual rendered size of each symbol layer using the provided render context.

See also

setSize()

See also

sizeUnit()

New in version 3.4.5.

Return type

float

sizeMapUnitScale(self) → QgsMapUnitScale

Returns the size map unit scale for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the map unit scale for the first symbol layer.

See also

sizeUnit()

See also

size()

New in version 2.16.

Return type

QgsMapUnitScale

sizeUnit(self) → QgsUnitTypes.RenderUnit

Returns the size units for the whole symbol (including all symbol layers).

Return type

QgsUnitTypes.RenderUnit

Returns

size units, or mixed units if symbol layers have different units

See also

setSizeUnit()

See also

size()

New in version 2.16.