Class: QgsRasterMarkerSymbolLayer

Raster marker symbol layer class.

Added in version 3.6.

Class Hierarchy

Inheritance diagram of qgis.core.QgsRasterMarkerSymbolLayer

Base classes

QgsMarkerSymbolLayer

Abstract base class for marker symbol layers.

QgsSymbolLayer

Abstract base class for symbol layers.

Subclasses

QgsAnimatedMarkerSymbolLayer

Animated marker symbol layer class.

Methods

calculateAspectRatio

Calculates the marker aspect ratio between width and height.

copyCommonProperties

Copies common properties to another layer.

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

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.

setCommonProperties

Sets common class properties from a properties 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

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.

Static Methods

create

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

createFromSld

Creates a new QgsRasterMarkerSymbolLayer from an SLD XML element.

resolvePaths

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

class qgis.core.QgsRasterMarkerSymbolLayer[source]

Bases: QgsMarkerSymbolLayer

__init__(path: str | None = '', 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

Parameters:
  • path (Optional[str] = '')

  • size (float = DEFAULT_SVGMARKER_SIZE)

  • angle (float = DEFAULT_SVGMARKER_ANGLE)

  • scaleMethod (Qgis.ScaleMethod = DEFAULT_SCALE_METHOD)

calculateAspectRatio(self, context: QgsSymbolRenderContext, scaledSize: float)[source]

Calculates the marker aspect ratio between width and height.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • scaledSize (float) -> (float) – size of symbol to render

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

copyCommonProperties(self, other: QgsRasterMarkerSymbolLayer | None)[source]

Copies common properties to another layer.

Added in version 3.26.

Parameters:

other (Optional[QgsRasterMarkerSymbolLayer])

static create(properties: Dict[str, Any] = {}) QgsSymbolLayer | None[source]

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

Parameters:

properties (Dict[str, Any] = {}) – QVariantMap properties object

Return type:

Optional[QgsSymbolLayer]

static createFromSld(element: QDomElement) QgsSymbolLayer | None[source]

Creates a new QgsRasterMarkerSymbolLayer from an SLD XML element.

Parameters:

element (QDomElement) – XML element containing SLD definition of symbol

Return type:

Optional[QgsSymbolLayer]

Returns:

new QgsRasterMarkerSymbolLayer

Added in version 3.44.

defaultAspectRatio(self) float[source]

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

Return type:

float

fixedAspectRatio(self) float[source]

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

See also

QgsSvgCache

Return type:

float

opacity(self) float[source]

Returns the marker opacity.

Return type:

float

Returns:

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

See also

setOpacity()

path(self) str[source]

Returns the marker raster image path.

See also

setPath()

Return type:

str

preservedAspectRatio(self) bool[source]

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

Return type:

bool

static resolvePaths(properties: Dict[str, Any], pathResolver: QgsPathResolver, saving: bool)[source]

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

Parameters:
setCommonProperties(self, properties: Dict[str, Any])[source]

Sets common class properties from a properties map.

Added in version 3.26.

Parameters:

properties (Dict[str, Any])

setFixedAspectRatio(self, ratio: float)[source]

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

See also

QgsSvgCache

setOpacity(self, opacity: float)[source]

Set the marker opacity.

Parameters:

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

See also

opacity()

setPath(self, path: str | None)[source]

Set the marker raster image path.

Parameters:

path (Optional[str]) – raster image path

See also

path()

setPreservedAspectRatio(self, par: bool) bool[source]

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[source]

Calculates the default marker aspect ratio between width and height.

Return type:

float

Returns:

the default aspect ratio value