Class: QgsRasterMarkerSymbolLayer

class qgis.core.QgsRasterMarkerSymbolLayer

Bases: QgsMarkerSymbolLayer

Raster marker symbol layer class.

New in version 3.6.

QgsRasterMarkerSymbolLayer(path: str = ‘’, size: float = DEFAULT_SVGMARKER_SIZE, angle: float = DEFAULT_SVGMARKER_ANGLE, scaleMethod: Qgis.ScaleMethod = DEFAULT_SCALE_METHOD) Constructs raster marker symbol layer with picture from given absolute path to a raster image file

Methods

bounds

param point:

calculateAspectRatio

Calculates the marker aspect ratio between width and height.

clone

rtype:

QgsRasterMarkerSymbolLayer

color

rtype:

QColor

copyDataDefinedProperties

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

copyPaintEffect

Copies paint effect of this layer to another symbol layer

create

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

defaultAspectRatio

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

fixedAspectRatio

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

layerType

rtype:

str

mapUnitScale

rtype:

QgsMapUnitScale

markerOffset

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

markerOffset2

markerOffsetWithWidthAndHeight

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

opacity

Returns the marker opacity.

path

Returns the marker raster image path.

preservedAspectRatio

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

properties

rtype:

Dict[str, Any]

renderPoint

param point:

resolvePaths

Turns relative paths in properties map to absolute when reading and vice versa when writing.

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setFixedAspectRatio

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

setMapUnitScale

param scale:

setOpacity

Set the marker opacity.

setPath

Set the marker raster image path.

setPreservedAspectRatio

Set preserved the marker aspect ratio between width and height.

updateDefaultAspectRatio

Calculates the default marker aspect ratio between width and height.

usesMapUnits

rtype:

bool

bounds(self, point: 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

color(self) QColor
Return type:

QColor

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, Any] = {}) QgsSymbolLayer

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

Parameters:

properties (Dict[str) – QVariantMap 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, Any]
Return type:

Dict[str, Any]

renderPoint(self, point: QPointF | QPoint, context: QgsSymbolRenderContext)
Parameters:
resolvePaths(properties: Dict[str, Any], 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, Any])

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

usesMapUnits(self) bool
Return type:

bool