Class: QgsMapLayerFactory

class qgis.core.QgsMapLayerFactory

Bases: sip.wrapper

Contains utility functions for creating map layers.

Added in version 3.18.1:

Methods

createLayer

Creates a map layer, given a uri, name, layer type and provider name.

typeFromString

Returns the map layer type corresponding a string value.

typeToString

Converts a map layer type to a string value.

class LayerOptions(transformContext: QgsCoordinateTransformContext)

Bases: sip.wrapper

Constructor for LayerOptions with transformContext.

QgsMapLayerFactory.LayerOptions(a0: QgsMapLayerFactory.LayerOptions)

loadAllStoredStyles
loadDefaultStyle
transformContext
createLayer(uri: str | None, name: str | None, type: Qgis.LayerType, options: QgsMapLayerFactory.LayerOptions, provider: str | None = '') QgsMapLayer | None

Creates a map layer, given a uri, name, layer type and provider name.

Caller takes ownership of the returned layer.

Added in version 3.22.

Parameters:
Return type:

Optional[QgsMapLayer]

typeFromString(string: str | None)

Returns the map layer type corresponding a string value.

Parameters:

string (Optional[str]) -> (Qgis.LayerType) – string to convert to map layer type

Returns:

  • converted map layer type

  • ok: will be set to True if string was successfully converted to a map layer type

See also

typeToString()

typeToString(type: Qgis.LayerType) str

Converts a map layer type to a string value.

See also

typeFromString()

Parameters:

type (Qgis.LayerType)

Return type:

str