Class: QgsRasterMarkerSymbolLayer

class qgis.core.QgsRasterMarkerSymbolLayer(path: str = '', size: float = DEFAULT_SVGMARKER_SIZE, angle: float = DEFAULT_SVGMARKER_ANGLE, scaleMethod: QgsSymbol.ScaleMethod = DEFAULT_SCALE_METHOD)

Bases: QgsMarkerSymbolLayer

Constructs raster marker symbol layer with picture from given absolute path to a raster image file

Raster marker symbol layer class.

New in version 3.6.

Parameters
  • path (str = '') –

  • size (float = DEFAULT_SVGMARKER_SIZE) –

  • angle (float = DEFAULT_SVGMARKER_ANGLE) –

  • scaleMethod

bounds(self, point: Union[QPointF, QPoint], context: QgsSymbolRenderContext) → QRectF
Parameters
Return type

QRectF

calculateAspectRatio(self, context: QgsSymbolRenderContext, scaledSize: float) → Tuple[float, bool]

Calculates the marker aspect ratio between width and height.

Parameters
  • context (QgsSymbolRenderContext) – symbol render context

  • scaledSize (float) – size of symbol to render

  • hasDataDefinedAspectRatio – will be set to True if marker has data defined aspectRatio

Return type

Tuple[float, bool]

clone(self)QgsRasterMarkerSymbolLayer
Return type

QgsRasterMarkerSymbolLayer

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)

Copies all data defined properties of this layer to another symbol layer.

Parameters

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer)

Copies paint effect of this layer to another symbol layer

Parameters

destLayer – destination layer

New in version 2.9.

create(properties: Dict[str, str] = {})QgsSymbolLayer

Creates a raster marker symbol layer from a string map of properties.

Parameters

properties (Dict[str) – QgsStringMap properties object

Return type

QgsSymbolLayer

defaultAspectRatio(self) → float

Returns the default marker aspect ratio between width and height, 0 if not yet calculated.

Return type

float

fixedAspectRatio(self) → float

Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

Return type

float

layerType(self) → str
Return type

str

mapUnitScale(self)QgsMapUnitScale
Return type

QgsMapUnitScale

markerOffset(self, context: QgsSymbolRenderContext) → Tuple[float, 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 – 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: QgsUnitTypes.RenderUnit, heightUnit: QgsUnitTypes.RenderUnit, widthMapUnitScale: QgsMapUnitScale, heightMapUnitScale: QgsMapUnitScale) → Tuple[float, float]

Note

available in Python bindings as markerOffset2

markerOffsetWithWidthAndHeight(self, context: QgsSymbolRenderContext, width: float, height: float) → Tuple[float, 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 – symbol render context

  • width – marker width

  • height – marker height

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

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

Note

available in Python as markerOffsetWithWidthAndHeight

opacity(self) → float

Returns the marker opacity.

Return type

float

Returns

opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

setOpacity()

path(self) → str

Returns the marker raster image path.

See also

setPath()

Return type

str

preservedAspectRatio(self) → bool

Returns the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0.

Return type

bool

properties(self) → Dict[str, str]
Return type

Dict[str, str]

renderPoint(self, point: Union[QPointF, QPoint], context: QgsSymbolRenderContext)
Parameters
resolvePaths(properties: Dict[str, str], pathResolver: QgsPathResolver, saving: bool)

Turns relative paths in properties map to absolute when reading and vice versa when writing. Used internally when reading/writing symbols.

New in version 3.0.

Parameters
  • properties (Dict[str) –

  • pathResolver (QgsPathResolver) –

  • saving (bool) –

restoreOldDataDefinedProperties(self, stringMap: Dict[str, str])

Restores older data defined properties from string map.

New in version 3.0.

setFixedAspectRatio(self, ratio: float)

Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

Parameters

ratio (float) – Fixed Aspect Ratio

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters

scale (QgsMapUnitScale) –

setOpacity(self, opacity: float)

Set the marker opacity.

Parameters

opacity (float) – opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

opacity()

setPath(self, path: str)

Set the marker raster image path.

Parameters

path (str) – raster image path

See also

path()

setPreservedAspectRatio(self, par: bool) → bool

Set preserved the marker aspect ratio between width and height.

Parameters

par (bool) – Preserved Aspect Ratio

Return type

bool

Returns

the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0

updateDefaultAspectRatio(self) → float

Calculates the default marker aspect ratio between width and height.

Return type

float

Returns

the default aspect ratio value