Class: QgsMapLayer¶
Base class for all map layer types.
This is the base class for all map layer types (vector, raster, mesh, point cloud, annotations, etc).
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone(), createMapRenderer(), readSymbology(), setTransformContext(), writeSymbology()
Class Hierarchy¶
Base classes¶
Subclasses¶
Represents a map layer containing a set of georeferenced annotations, e.g. markers, lines, polygons or text items. |
|
Represents a vector layer which manages a vector based dataset. |
|
A map layer which consists of a set of child layers, where all component layers are rendered as a single flattened object during map renders. |
|
Represents a mesh layer supporting display of data on structured or unstructured meshes. |
|
Base class for plugin layers. |
|
Represents a map layer supporting display of point clouds. |
|
Represents a raster layer. |
|
Represents a map layer supporting display of tiled scene objects. |
|
Implements a map layer that is dedicated to rendering of vector tiles. |
- class qgis.core.QgsMapLayer[source]¶
Bases:
QObject- __init__(type: Qgis.LayerType = Qgis.LayerType.Vector, name: str | None = '', source: str | None = '')
Constructor for QgsMapLayer
- Parameters:
type (Qgis.LayerType = Qgis.LayerType.Vector) – layer type
name (Optional[str] = '') – display name for the layer
source (Optional[str] = '') – datasource of layer
- Actions = 64¶
- AllAttributeCategories = 560¶
- AllStyleCategories = 262143¶
- AllVisualStyleCategories = 270¶
- AttributeTable = 512¶
- CustomProperties = 2048¶
- Diagrams = 256¶
- Elevation = 65536¶
- Fields = 16¶
- FlagDontResolveLayers = 1¶
- FlagForceReadOnly = 8¶
- FlagReadExtentFromXml = 4¶
- FlagTrustLayerMetadata = 2¶
- Forms = 32¶
- GeometryOptions = 4096¶
- Identifiable = 1¶
- Labeling = 8¶
- LayerConfiguration = 1¶
- class LayerFlag¶
Bases:
int
- class LayerFlags¶
- class LayerFlags(f: QgsMapLayer.LayerFlags | QgsMapLayer.LayerFlag)
- class LayerFlags(a0: QgsMapLayer.LayerFlags)
Bases:
object
- class LayerType(*values)¶
Bases:
IntEnumTypes of layers that can be added to a map
Added in version 3.30..
Vector: Vector layerAvailable as
QgsMapLayer.VectorLayerin older QGIS releases.Raster: Raster layerAvailable as
QgsMapLayer.RasterLayerin older QGIS releases.Plugin: Plugin based layerAvailable as
QgsMapLayer.PluginLayerin older QGIS releases.Mesh: Mesh layer. Added in QGIS 3.2Available as
QgsMapLayer.MeshLayerin older QGIS releases.VectorTile: Vector tile layer. Added in QGIS 3.14Available as
QgsMapLayer.VectorTileLayerin older QGIS releases.Annotation: Contains freeform, georeferenced annotations. Added in QGIS 3.16Available as
QgsMapLayer.AnnotationLayerin older QGIS releases.PointCloud: Point cloud layer. Added in QGIS 3.18Available as
QgsMapLayer.PointCloudLayerin older QGIS releases.Group: Composite group layer. Added in QGIS 3.24Available as
QgsMapLayer.GroupLayerin older QGIS releases.TiledScene: Tiled scene layer. Added in QGIS 3.34
- Legend = 32768¶
- MapTips = 128¶
- Metadata = 1¶
- Notes = 131072¶
- Private = 8¶
- class PropertyType¶
Bases:
int
- class ReadFlag¶
Bases:
int
- class ReadFlags¶
- class ReadFlags(f: QgsMapLayer.ReadFlags | QgsMapLayer.ReadFlag)
- class ReadFlags(a0: QgsMapLayer.ReadFlags)
Bases:
object
- Relations = 8192¶
- Removable = 2¶
- Rendering = 1024¶
- class SaveStyleResult(*values)¶
Bases:
IntEnumResults of saving styles to database.
Added in version 4.0.
Success: Both QML and SLD formats were successfully written to the database.QmlGenerationFailed: Generation of the QML failed, and was not written to the database.SldGenerationFailed: Generation of the SLD failed, and was not written to the database.DatabaseWriteFailed: An error occurred when attempting to write to the database.
- DatabaseWriteFailed = 4¶
- QmlGenerationFailed = 1¶
- SldGenerationFailed = 2¶
- Success = 0¶
- class SaveStyleResults¶
- class SaveStyleResults(f: QgsMapLayer.SaveStyleResults | QgsMapLayer.SaveStyleResult)
- class SaveStyleResults(a0: QgsMapLayer.SaveStyleResults)
Bases:
object
- Searchable = 4¶
- Style = 0¶
- class StyleCategories¶
- class StyleCategories(f: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory)
- class StyleCategories(a0: QgsMapLayer.StyleCategories)
Bases:
object
- class StyleCategory¶
Bases:
int
- Symbology = 2¶
- Symbology3D = 4¶
- Temporal = 16384¶
- abstract(self) str[source]¶
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.abstract instead.- Return type:
str
- virtual accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool[source]¶
Accepts the specified symbology
visitor, causing it to visit all symbols associated with the layer.Returns
Trueif the visitor should continue visiting other objects, orFalseif visiting should be canceled.Added in version 3.10.
accept(self, visitor: Optional[QgsObjectEntityVisitorInterface], context:
QgsObjectVisitorContext) -> bool Accepts the specified objectvisitor, causing it to visit all relevant objects associated with the layer.Returns
Trueif the visitor should continue visiting other objects, orFalseif visiting should be canceled.Added in version 4.0.
- Parameters:
visitor (Optional[QgsStyleEntityVisitorInterface])
- Return type:
bool
- appendError(self, error: QgsErrorMessage)[source]¶
Add error message
- Parameters:
error (QgsErrorMessage)
- attribution(self) str[source]¶
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.attribution instead.- Return type:
str
- attributionUrl(self) str[source]¶
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.attributionUrl instead.- Return type:
str
- autoRefreshInterval(self) int[source]¶
Returns the auto refresh interval (in milliseconds). Note that auto refresh is only active when
hasAutoRefreshEnabled()isTrue.See also
See also
- Return type:
int
- signal autoRefreshIntervalChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- autoRefreshMode(self) Qgis.AutoRefreshMode[source]¶
Returns the layer’s automatic refresh mode.
See also
See also
Added in version 3.34.
- Return type:
- signal beforeResolveReferences[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- blendMode(self) QPainter.CompositionMode[source]¶
Returns the current blending mode for a layer.
See also
- Return type:
QPainter.CompositionMode
- signal blendModeChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- abstract clone(self) QgsMapLayer | None[source]¶
Returns a new instance equivalent to this one except for the id which is still unique.
- Return type:
Optional[QgsMapLayer]
- Returns:
a new layer instance
clone(self, layer: Optional[QgsMapLayer]) Copies attributes like name, short name, … into another layer.
- Parameters:
layer – The copy recipient
- signal configChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- abstract createMapRenderer(self, rendererContext: QgsRenderContext) QgsMapLayerRenderer | None[source]¶
Returns new instance of
QgsMapLayerRendererthat will be used for rendering of given context- Parameters:
rendererContext (QgsRenderContext)
- Return type:
Optional[QgsMapLayerRenderer]
- crs(self) QgsCoordinateReferenceSystem[source]¶
Returns the layer’s spatial reference system.
Warning
Since QGIS 3.38, consider using
crs3D()whenever transforming 3D data or whenever z/elevation value handling is important.See also
See also
See also
See also
- Return type:
- crs3D(self) QgsCoordinateReferenceSystem[source]¶
Returns the CRS to use for the layer when transforming 3D data, or when z/elevation value handling is important.
The returned CRS will take into account
verticalCrs()when appropriate, e.g. it may return a compound CRS consisting ofcrs()+verticalCrs(). This method may still return a 2D CRS, e.g in the case thatcrs()is a 2D CRS and noverticalCrs()has been set for the layer. CheckQgsCoordinateReferenceSystem.type()on the returned value to determine the type of CRS returned by this method.Warning
It is NOT guaranteed that the returned CRS will actually be a 3D CRS, but rather it is guaranteed that the returned CRS is ALWAYS the most appropriate CRS to use when handling 3D data.
See also
See also
See also
Added in version 3.38.
- Return type:
- signal crs3DChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal crsChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- customProperties(self) QgsObjectCustomProperties¶
Read all custom properties from layer. Properties are stored in a map and saved in project file.
See also
Added in version 3.14.
- Return type:
- customProperty(self, value: str | None, defaultValue: Any = None) Any[source]¶
Read a custom property from layer. Properties are stored in a map and saved in project file.
See also
- Parameters:
value (Optional[str])
defaultValue (Any = None)
- Return type:
- signal customPropertyChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- customPropertyKeys(self) List[str][source]¶
Returns list of all keys within custom properties. Properties are stored in a map and saved in project file.
See also
- Return type:
List[str]
- signal dataChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual dataProvider(self) QgsDataProvider | None[source]¶
Returns the layer’s data provider, it may be
None.- Return type:
Optional[QgsDataProvider]
- signal dataSourceChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- dataUrl(self) str[source]¶
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.dataUrl instead.- Return type:
str
- dataUrlFormat(self) str[source]¶
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.dataUrlFormat instead.- Return type:
str
- virtual decodedSource(self, source: str | None, dataProvider: str | None, context: QgsReadWriteContext) str[source]¶
Called by
readLayerXML(), used by derived classes to decode provider’s specific data source from project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)- Parameters:
source (Optional[str]) – data source to decode, typically read from layer’s DOM element “datasource”
dataProvider (Optional[str]) – string identification of data provider (e.g. “ogr”), typically read from layer’s DOM element
context (QgsReadWriteContext) – reading context (e.g. for conversion between relative and absolute paths)
- Return type:
str
- Returns:
decoded source, typically to be used as the layer’s datasource
Added in version 3.2.
- virtual deleteStyleFromDatabase(self, styleId: str | None)[source]¶
Deletes a style from the database
- Parameters:
styleId (Optional[str]) -> (bool) – the provider’s layer_styles table id of the style to delete
- Returns:
Truein case of successmsgError: a descriptive error message if any occurs
- virtual dependencies(self) Set[QgsMapLayerDependency]¶
Gets the list of dependencies. This includes data dependencies set by the user (
setDataDependencies()) as well as dependencies given by the provider- Return type:
- Returns:
a set of
QgsMapLayerDependency
- signal dependenciesChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal editingStarted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal editingStopped[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual elevationProperties(self) QgsMapLayerElevationProperties | None[source]¶
Returns the layer’s elevation properties. This may be
None, depending on the layer type.Added in version 3.18.
- Return type:
Optional[QgsMapLayerElevationProperties]
- emitStyleChanged(self)[source]¶
Triggers an emission of the
styleChanged()signal.
- virtual encodedSource(self, source: str | None, context: QgsReadWriteContext) str[source]¶
Called by
writeLayerXML(), used by derived classes to encode provider’s specific data source to project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)- Parameters:
source (Optional[str]) – data source to encode, typically
QgsMapLayer.source()context (QgsReadWriteContext) – writing context (e.g. for conversion between relative and absolute paths)
- Return type:
str
- Returns:
encoded source, typically to be written in the DOM element “datasource”
Added in version 3.2.
- virtual error(self) QgsError[source]¶
Gets current status error. This error describes some principal problem for which layer cannot work and thus is not valid. It is not last error after accessing data by
draw()etc.- Return type:
- exportNamedMetadata(self, doc: QDomDocument, errorMsg: str | None)[source]¶
Export the current metadata of this layer as named metadata in a QDomDocument
- Parameters:
doc (QDomDocument) – the target QDomDocument
errorMsg (Optional[str]) – will be set to a descriptive message if an error occurs
- virtual exportNamedStyle(self, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext(), categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) str[source]¶
Export the properties of this layer as named style in a QDomDocument
- Parameters:
doc (QDomDocument) – the target QDomDocument
context (
QgsReadWriteContext= QgsReadWriteContext()) – read write contextcategories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to export during the execution of writeSymbology
- Return type:
str
- Returns:
a descriptive message if an error occurs
- virtual exportSldStyle(self, doc: QDomDocument, errorMsg: str | None)[source]¶
Export the properties of this layer as SLD style in a QDomDocument
- Parameters:
doc (QDomDocument) – the target QDomDocument
errorMsg (Optional[str]) – will be set to a descriptive message if an error occurs during the execution of writeSymbology
Deprecated since version 3.44: Use
exportSldStyleV3()instead.
- virtual exportSldStyleV2(self, doc: QDomDocument, errorMsg: str | None, exportContext: QgsSldExportContext)[source]¶
Export the properties of this layer as SLD style in a QDomDocument
- Parameters:
doc (QDomDocument) – the target QDomDocument
errorMsg (Optional[str]) – will be set to a descriptive message if an error occurs during the execution of
writeSymbology()exportContext (QgsSldExportContext) – SLD export context
Deprecated since version 3.44: Use
exportSldStyleV3()instead.
- virtual exportSldStyleV3(self, exportContext: QgsSldExportContext) QDomDocument[source]¶
Export the properties of this layer as SLD style in a QDomDocument.
Errors and warnings raised during the conversion should be retrieved from
exportContext.- Parameters:
exportContext (QgsSldExportContext) – SLD export context
Added in version 3.44.
- Return type:
QDomDocument
- static extensionPropertyType(type: QgsMapLayer.PropertyType) str[source]¶
Returns the extension of a Property.
- Return type:
str
- Returns:
The extension
- Parameters:
type (QgsMapLayer.PropertyType)
- virtual extent(self) QgsRectangle[source]¶
Returns the extent of the layer.
- Return type:
- virtual extent3D(self) QgsBox3D[source]¶
Returns the 3D extent of the layer.
Added in version 3.36.
- Return type:
- flags(self) QgsMapLayer.LayerFlags[source]¶
Returns the flags for this layer.
Note
Flags are options specified by the user used for the UI but are not preventing any API call. For instance, even if the Removable flag is not set, the layer can still be removed with the API but the action will not be listed in the legend menu.
See also
Added in version 3.4.
- Return type:
- signal flagsChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- static formatLayerName(name: str | None) str[source]¶
A convenience function to capitalize and format a layer
name.- Parameters:
name (Optional[str])
- Return type:
str
- static generateId(layerName: str | None) str[source]¶
Generates an unique identifier for this layer, the generate ID is prefixed by
layerNameAdded in version 3.8.
- Parameters:
layerName (Optional[str])
- Return type:
str
- virtual getStyleFromDatabase(self, styleId: str | None)[source]¶
Returns the named style corresponding to style id provided
- Parameters:
styleId (Optional[str]) -> (str)
- hasAutoRefreshEnabled(self) bool[source]¶
Returns
Trueif auto refresh is enabled for the layer.See also
See also
Deprecated since version 3.40: Use
autoRefreshMode()instead.- Return type:
bool
- hasDependencyCycle(self, a0: Iterable[QgsMapLayerDependency]) bool[source]¶
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return
False, because circular dependencies are now correctly managed.Deprecated since version 3.10.
- Parameters:
a0 (Iterable[QgsMapLayerDependency])
- Return type:
bool
- virtual hasMapTips(self) bool[source]¶
Returns
Trueif the layer contains map tips.See also
See also
- Return type:
bool
- hasScaleBasedVisibility(self) bool[source]¶
Returns whether scale based visibility is enabled for the layer.
- Return type:
bool
- Returns:
Trueif scale based visibility is enabled
See also
See also
See also
See also
- virtual htmlMetadata(self) str[source]¶
Obtain a formatted HTML string containing assorted metadata for this layer.
- Return type:
str
- id(self) str[source]¶
Returns the layer’s unique ID, which is used to access this layer from
QgsProject.See also
See also
- Return type:
str
- signal idChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- importNamedMetadata(self, document: QDomDocument, errorMessage: str | None) bool[source]¶
Import the metadata of this layer from a QDomDocument
- Parameters:
document (QDomDocument) – source QDomDocument
errorMessage (Optional[str]) – will be set to a descriptive message if an error occurs
- Return type:
bool
- Returns:
Trueon success
- virtual importNamedStyle(self, doc: QDomDocument, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)[source]¶
Import the properties of this layer from a QDomDocument
- Parameters:
doc (QDomDocument) – source QDomDocument
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) -> (bool) – the style categories to import
- Returns:
Trueon successerrorMsg: a descriptive message if an error occurs during the execution of
readSymbology()
- invalidateWgs84Extent(self)[source]¶
Invalidates the WGS84 extent. If FlagTrustLayerMetadata is enabled, the extent is not invalidated because we want to trust metadata whatever happens.
Added in version 3.20.
- isInScaleRange(self, scale: float) bool[source]¶
Tests whether the layer should be visible at the specified
scale. Thescalevalue indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.- Return type:
bool
- Returns:
Trueif the layer is visible at the given scale.
See also
See also
See also
- Parameters:
scale (float)
- virtual isModified(self) bool[source]¶
Returns
Trueif the layer has been modified since last commit/save.Note
default implementation returns
False.Added in version 3.22.
- Return type:
bool
- isRefreshOnNotifyEnabled(self) bool[source]¶
Returns
Trueif the refresh on provider nofification is enabled- Return type:
bool
- virtual isSpatial(self) bool[source]¶
Returns
Trueif the layer is considered a spatial layer, ie it has some form of geometry associated with it.- Return type:
bool
- virtual isTemporary(self) bool[source]¶
Returns
Trueif the layer is considered a temporary layer.These include memory-only layers such as those created by the “memory” data provider, layers stored inside a local temporary folder (such as the “/tmp” folder on Linux) or layer with temporary data (as temporary mesh layer dataset)
Added in version 3.10.1.
- Return type:
bool
- isValid(self) bool[source]¶
Returns the status of the layer. An invalid layer is one which has a bad datasource or other problem. Child classes set this flag when initialized.
- Return type:
bool
- Returns:
Trueif the layer is valid and can be accessed
- signal isValidChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- keywordList(self) str[source]¶
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.keywordList instead.- Return type:
str
- signal layerModified[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- legend(self) QgsMapLayerLegend | None[source]¶
Can be
None.- Return type:
Optional[QgsMapLayerLegend]
- signal legendChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- legendPlaceholderImage(self) str[source]¶
Returns path to the placeholder image or an empty string if a generated legend is shown
- Return type:
str
- Returns:
placeholder image path
Added in version 3.22.
- legendUrl(self) str[source]¶
Returns the URL for the layer’s legend.
Deprecated since version 3.44: Use
serverProperties()->:py:func:~QgsMapLayer.legendUrl instead.- Return type:
str
- legendUrlFormat(self) str[source]¶
Returns the format for a URL based layer legend.
Deprecated since version 3.44: Use
serverProperties()->:py:func:~QgsMapLayer.legendUrlFormat instead.- Return type:
str
- virtual listStylesInDatabase(self)[source]¶
Lists all the style in db split into related to the layer and not related to
- Returns:
the number of styles related to current layer (-1 on not implemented)
ids: the list in which will be stored the style db ids
names: the list in which will be stored the style names
descriptions: the list in which will be stored the style descriptions
msgError: a descriptive error message if any occurs
Note
Since QGIS 3.2 Styles related to the layer are ordered with the default style first then by update time for Postgres, MySQL and Spatialite.
- virtual loadDefaultMetadata(self)[source]¶
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users metadata table in their personal qgis.db)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to load the default metadata.
- virtual loadDefaultStyle(self)[source]¶
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to load the default style.
See also
- virtual loadNamedMetadata(self, uri: str | None)[source]¶
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- Parameters:
uri (Optional[str]) -> (str) – the file name or other URI for the metadata file. First an attempt will be made to see if this is a file and load that, if that fails the qgis.db metadata table will be consulted to see if there is a metadata who’s key matches the URI.
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to load the default metadata.
- loadNamedMetadataFromDatabase(self, db: str | None, uri: str | None, qmd: str | None) bool[source]¶
Retrieve a named metadata for this layer from a sqlite database.
- Parameters:
db (Optional[str]) – path to sqlite database
uri (Optional[str]) – uri for table
qmd (Optional[str]) – will be set to QMD xml metadata content from database
- Return type:
bool
- Returns:
Trueif style was successfully loaded
- virtual loadNamedStyle(self, theURI: str | None, loadFromLocalDb: bool, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories, flags: Qgis.LoadStyleFlags | Qgis.LoadStyleFlag = Qgis.LoadStyleFlags())[source]¶
Loads a named style from file/local db/datasource db
- Parameters:
theURI (Optional[str]) – the URI of the style or the URI of the layer
loadFromLocalDb (bool) – if
Trueforces to load from local db instead of datasource onecategories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be loaded.
flags (Union[Qgis.LoadStyleFlags, Qgis.LoadStyleFlag] = Qgis.LoadStyleFlags()) -> (str) – flags controlling how the style should be loaded (since QGIS 3.38)
- Returns:
status message, which may indicate success or contain an error message
resultFlag:
Trueif a named style is correctly loaded
loadNamedStyle(self, uri: Optional[str], categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories, flags: Union[Qgis.LoadStyleFlags, Qgis.LoadStyleFlag] = Qgis.LoadStyleFlags()) -> (str, bool) Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Parameters:
uri – the file name or other URI for the style file. First an attempt will be made to see if this is a file and load that, if that fails the qgis.db styles table will be consulted to see if there is a style who’s key matches the URI.
categories – the style categories to be loaded.
flags – flags controlling how the style should be loaded (since QGIS 3.38)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to load the default style.
See also
- virtual loadNamedStyleFromDatabase(self, db: str | None, uri: str | None)[source]¶
Retrieve a named style for this layer from a sqlite database.
- Parameters:
db (Optional[str]) – path to sqlite database
uri (Optional[str]) -> (bool) – uri for table
- Returns:
Trueif style was successfully loadedqml: QML style content from database
- virtual loadSldStyle(self, uri: str | None)[source]¶
Attempts to style the layer using the formatting from an SLD type file.
- Parameters:
uri (Optional[str]) -> (str) – uri of source SLD file
- Returns:
a string with any status or error messages
resultFlag:
Falseif the SLD file could not be loaded
See also
- mapTipTemplate(self) str[source]¶
The mapTip is a pretty, html representation for feature information.
It may also contain embedded expressions.
Added in version 3.30.
- Return type:
str
- signal mapTipTemplateChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- mapTipsEnabled(self) bool[source]¶
Returns true if map tips are enabled for this layer
Added in version 3.32.
- Return type:
bool
- signal mapTipsEnabledChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- maximumScale(self) float[source]¶
Returns the maximum map scale (i.e. most “zoomed in” scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
Note
Scale based visibility is only used if
setScaleBasedVisibility()is set toTrue.See also
See also
See also
See also
- Return type:
float
- metadata(self) QgsLayerMetadata¶
Returns a reference to the layer’s metadata store.
See also
See also
- Return type:
- signal metadataChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual metadataUri(self) str[source]¶
Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- Return type:
str
- Returns:
a string with the metadata file name
- metadataUrl(self) str[source]¶
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request. MetadataUrl is a a link to the detailed, standardized metadata about the data. Since QGIS 3.22, it returns the first metadata URL link.
- Return type:
str
- Returns:
the layer metadata URL
See also
Deprecated since version 3.22.
- metadataUrlFormat(self) str[source]¶
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request. MetadataUrlType indicates how the metadata is structured. Since QGIS 3.22, it returns the first metadata URL format.
- Return type:
str
- Returns:
the layer metadata format
See also
Deprecated since version 3.22.
- metadataUrlType(self) str[source]¶
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request. MetadataUrlType indicates the standard to which the metadata complies. Since QGIS 3.22, it returns the first metadata URL type.
- Return type:
str
- Returns:
the layer metadata type
See also
Deprecated since version 3.22.
- minimumScale(self) float[source]¶
Returns the minimum map scale (i.e. most “zoomed out” scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
Note
Scale based visibility is only used if
setScaleBasedVisibility()is set toTrue.See also
See also
See also
See also
- Return type:
float
- signal nameChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual opacity(self) float[source]¶
Returns the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque).
See also
See also
Note
Prior to QGIS 3.18, this method was available for vector layers only
Added in version 3.18.
- Return type:
float
- signal opacityChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- originalXmlProperties(self) str[source]¶
Returns the XML properties of the original layer as they were when the layer was first read from the project file. In case of new layers this is normally empty.
The storage format for the XML is qlr
Added in version 3.6.
- Return type:
str
- virtual profileSource(self) QgsAbstractProfileSource | None[source]¶
Returns the layer’s profile source if it has profile capabilities. This may be
None, depending on the layer type.Added in version 3.44.
- Return type:
Optional[QgsAbstractProfileSource]
- project(self) QgsProject | None[source]¶
Returns the parent project if this map layer is added to a project. Otherwise returns
NoneAdded in version 3.18.
- Return type:
Optional[QgsProject]
- virtual properties(self) Qgis.MapLayerProperties[source]¶
Returns the map layer properties of this layer.
Note
properties()differ fromflags()in thatflags()are user settable, and reflect options that users can enable for map layers. In contrastproperties()are reflections of inherent capabilities for the layer, which cannot be directly changed by users.Added in version 3.22.
- Return type:
- providerMetadata(self) QgsProviderMetadata | None[source]¶
Returns the layer data provider’s metadata, it may be
None.Added in version 3.40.
- Return type:
Optional[QgsProviderMetadata]
- static providerReadFlags(layerNode: QDomNode, layerReadFlags: QgsMapLayer.ReadFlags | QgsMapLayer.ReadFlag) Qgis.DataProviderReadFlags[source]¶
Returns provider read flag deduced from layer read flags
layerReadFlagsand a dom nodelayerNodethat describes a layer (corresponding tomaplayertag in a DOM document project file read byQgsProject). This static method is used when loading a project.Added in version 3.32.
- Parameters:
layerNode (QDomNode)
layerReadFlags (Union[QgsMapLayer.ReadFlags, QgsMapLayer.ReadFlag])
- Return type:
- providerType(self) str[source]¶
Returns the provider type (provider key) for this layer
- Return type:
str
- publicSource(self, hidePassword: bool = False) str[source]¶
Gets a version of the internal layer definition that has sensitive bits removed (for example, the password). This function should be used when displaying the source name for general viewing.
- Parameters:
hidePassword (bool = False) –
Trueto replace the value of credentials with ‘xxxxxxxx’,Falseto completely remove credentials (key and value). Since QGIS 3.34
See also
- Return type:
str
- readCommonStyle(self, layerElement: QDomElement, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)[source]¶
Read style data common to all layer types
- Parameters:
layerElement (QDomElement)
context (QgsReadWriteContext)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)
- readCustomProperties(self, layerNode: QDomNode, keyStartsWith: str | None = '')[source]¶
Read custom properties from project file.
- Parameters:
layerNode (QDomNode) – note to read from
keyStartsWith (Optional[str] = '') – reads only properties starting with the specified string (or all if the string is empty)
- readLayerXml(self, layerElement: QDomElement, context: QgsReadWriteContext, flags: QgsMapLayer.ReadFlags | QgsMapLayer.ReadFlag = QgsMapLayer.ReadFlags(), preloadedProvider: QgsDataProvider | None = None) bool[source]¶
Sets state from DOM document
- Parameters:
layerElement (QDomElement) – The DOM element corresponding to
maplayertagcontext (QgsReadWriteContext) – writing context (e.g. for conversion between relative and absolute paths)
flags (Union[QgsMapLayer.ReadFlags, QgsMapLayer.ReadFlag] = QgsMapLayer.ReadFlags()) – optional argument which can be used to control layer reading behavior.
preloadedProvider (Optional[QgsDataProvider] = None) – optional preloaded data provider that will be used as data provider for this layer, takes ownership (since QGIS 3.32)
Note
The DOM node corresponds to a DOM document project file XML element read by
QgsProject.This, in turn, calls
readXml()(and thenreadSymbology()), which is overridable by sub-classes so that they can read their own specific state from the given DOM node.Invoked by
QgsProject.read().- Return type:
bool
- Returns:
Trueif successful
- virtual readSld(self, node: QDomNode, errorMessage: str | None) bool[source]¶
- Parameters:
node (QDomNode)
errorMessage (Optional[str])
- Return type:
bool
- virtual readStyle(self, node: QDomNode, errorMessage: str | None, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool[source]¶
Read the style for the current layer from the DOM node supplied.
- Parameters:
node (QDomNode) – node that will contain the style definition for this layer.
errorMessage (Optional[str]) – reference to string that will be updated with any error messages
context (QgsReadWriteContext) – reading context (used for transform from relative to absolute paths)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be read
- Return type:
bool
- Returns:
Truein case of success.
Note
To be implemented in subclasses. Default implementation does nothing and returns
False.
- readStyleManager(self, layerNode: QDomNode)[source]¶
Read style manager’s configuration (if any). To be called by subclasses.
- Parameters:
layerNode (QDomNode)
- abstract readSymbology(self, node: QDomNode, errorMessage: str | None, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool[source]¶
Read the symbology for the current layer from the DOM node supplied.
- Parameters:
node (QDomNode) – node that will contain the symbology definition for this layer.
errorMessage (Optional[str]) – reference to string that will be updated with any error messages
context (QgsReadWriteContext) – reading context (used for transform from relative to absolute paths)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be read
- Return type:
bool
- Returns:
Truein case of success.
- virtual readXml(self, layer_node: QDomNode, context: QgsReadWriteContext) bool[source]¶
Called by
readLayerXML(), used by children to read state specific to them from project files.- Parameters:
layer_node (QDomNode)
context (QgsReadWriteContext)
- Return type:
bool
- signal recalculateExtents[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- refreshOnNotifyMessage(self) str[source]¶
Returns the message that should be notified by the provider to triggerRepaint
- Return type:
str
- removeCustomProperty(self, key: str | None)[source]¶
Remove a custom property from layer. Properties are stored in a map and saved in project file.
See also
- Parameters:
key (Optional[str])
- renderer3D(self) QgsAbstract3DRenderer | None[source]¶
Returns 3D renderer associated with the layer. May be
None.- Return type:
Optional[QgsAbstract3DRenderer]
- signal renderer3DChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal rendererChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal repaintRequested[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal request3DUpdate[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual resolveReferences(self, project: QgsProject | None)[source]¶
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
- Parameters:
project (Optional[QgsProject])
- virtual saveDefaultMetadata(self)[source]¶
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to save the default metadata.
- virtual saveDefaultStyle(self, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory)[source]¶
Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Parameters:
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory]) -> (str) – the style categories to be saved (since QGIS 3.26)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to save the default style.
See also
See also
saveDefaultStyle(self) -> (str, bool) Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to save the default style.
See also
See also
Deprecated since version 3.26.
- saveNamedMetadata(self, uri: str | None)[source]¶
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- Parameters:
uri (Optional[str]) -> (str) – the file name or other URI for the metadata file. First an attempt will be made to see if this is a file and save to that, if that fails the qgis.db metadata table will be used to create a metadata entry who’s key matches the URI.
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to save the default metadata.
- virtual saveNamedStyle(self, uri: str | None, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)[source]¶
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Parameters:
uri (Optional[str]) – the file name or other URI for the style file. First an attempt will be made to see if this is a file and save to that, if that fails the qgis.db styles table will be used to create a style entry who’s key matches the URI.
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) -> (str) – the style categories to be saved.
- Returns:
a string with any status messages
resultFlag:
Falseif we did not manage to save the default style.
See also
- virtual saveSldStyle(self, uri: str | None)[source]¶
Saves the properties of this layer to an SLD format file.
- Parameters:
uri (Optional[str]) -> (str) – uri of destination for exported SLD file.
- Returns:
a string with any status or error messages
resultFlag:
Falseif the SLD file could not be generated
See also
See also
- virtual saveSldStyleV2(self, exportContext: QgsSldExportContext)[source]¶
Saves the properties of this layer to an SLD format file.
- Parameters:
exportContext (
QgsSldExportContext) -> (str) – SLD export context- Returns:
a string with any status or error messages
resultFlag:
Falseif the SLD file could not be generated
See also
Added in version 3.30.
- virtual saveStyleToDatabase(self, name: str | None, description: str | None, useAsDefault: bool, uiFileContent: str | None, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) str[source]¶
Saves QML and SLD representations of the layer’s style to a table in the database.
- Parameters:
name (Optional[str]) – Style name
description (Optional[str]) – A description of the style
useAsDefault (bool) – Set to
Trueif style should be used as the default style for the layeruiFileContent (Optional[str])
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be saved.
Note
Prior to QGIS 3.24, this method would show a message box warning when a style with the same
styleNamealready existed to confirm replacing the style with the user. Since 3.24, calling this method will ALWAYS overwrite any existing style with the same name. UseQgsProviderRegistry.styleExists()to test in advance if a style already exists and handle this appropriately in your client code.- Return type:
str
- Returns:
msgError: a descriptive error message if any occurs
Deprecated since version 4.0: Use
saveStyleToDatabaseV2()instead.
- saveStyleToDatabaseV2(self, name: str | None, description: str | None, useAsDefault: bool, uiFileContent: str | None, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)[source]¶
Saves QML and SLD representations of the layer’s style to a table in the database.
- Parameters:
name (Optional[str]) – Style name
description (Optional[str]) – A description of the style
useAsDefault (bool) – Set to
Trueif style should be used as the default style for the layeruiFileContent (Optional[str])
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) -> (QgsMapLayer.SaveStyleResults) – the style categories to be saved.
- Returns:
flags representing whether QML or SLD storing was successful
msgError: a descriptive error message if any occurs
Added in version 4.0.
- virtual selectionProperties(self) QgsMapLayerSelectionProperties | None[source]¶
Returns the layer’s selection properties. This may be
None, depending on the layer type.Added in version 3.34.
- Return type:
Optional[QgsMapLayerSelectionProperties]
- serverProperties(self) QgsMapLayerServerProperties | None[source]¶
Returns QGIS Server Properties for the map layer
Added in version 3.22.
- Return type:
Optional[QgsMapLayerServerProperties]
- setAbstract(self, abstract: str | None)[source]¶
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setAbstract instead.- Parameters:
abstract (Optional[str])
- setAttribution(self, attrib: str | None)[source]¶
Sets the attribution of the layerused by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setAttribution instead.- Parameters:
attrib (Optional[str])
- setAttributionUrl(self, attribUrl: str | None)[source]¶
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setAttributionUrl instead.- Parameters:
attribUrl (Optional[str])
- setAutoRefreshEnabled(self, enabled: bool)[source]¶
Sets whether auto refresh is enabled for the layer.
See also
See also
Deprecated since version 3.40: Use
setAutoRefreshMode()instead.- Parameters:
enabled (bool)
- setAutoRefreshInterval(self, interval: int)[source]¶
Sets the auto refresh interval (in milliseconds) for the layer. This will cause the layer to be automatically redrawn on a matching interval. Note that auto refresh must be enabled by calling
setAutoRefreshMode().Note that auto refresh triggers deferred repaints of the layer. Any map canvas must be refreshed separately in order to view the refreshed layer.
See also
See also
- Parameters:
interval (int)
- setAutoRefreshMode(self, mode: Qgis.AutoRefreshMode)[source]¶
Sets the automatic refresh mode for the layer.
See also
See also
Added in version 3.34.
- Parameters:
mode (Qgis.AutoRefreshMode)
- setBlendMode(self, blendMode: QPainter.CompositionMode)[source]¶
Set the blending mode used for rendering a layer.
- Parameters:
blendMode (QPainter.CompositionMode) – new blending mode
See also
- setCrs(self, srs: QgsCoordinateReferenceSystem, emitSignal: bool = True)[source]¶
Sets layer’s spatial reference system.
If
emitSignalisTrue, changing the CRS will trigger acrsChanged()signal. Additionally, ifcrsis a compound CRS, then theverticalCrsChanged()signal will also be emitted.See also
See also
See also
- Parameters:
emitSignal (bool = True)
- setCustomProperties(self, properties: QgsObjectCustomProperties)[source]¶
Set custom properties for layer. Current properties are dropped.
- Parameters:
properties (QgsObjectCustomProperties)
- setCustomProperty(self, key: str | None, value: Any)[source]¶
Set a custom property for layer. Properties are stored in a map and saved in project file.
See also
See also
- Parameters:
key (Optional[str])
value (Any)
- setDataSource(self, dataSource: str | None, baseName: str | None = '', provider: str | None = '', loadDefaultStyleFlag: bool = False)[source]¶
Updates the data source of the layer.
The
dataSourceargument must specify the new data source string for the layer. The format varies depending on the specified dataproviderin use. SeeQgsDataSourceUriand the documentation for the variousQgsMapLayersubclasses for further details on data source strings.The
baseNameargument specifies the user-visible name to use for the layer. (Seename()orsetName()). If not specified, then the current name will be left unchanged (since QGIS 3.40).The
providerargument is used to specify the unique key of the data provider to use for the layer. This must match one of the values returned byQgsProviderRegistry.instance()->:py:func:~QgsMapLayer.providerList. (SeeproviderType()). If not specified, then the current data provider will be used (since QGIS 3.40).If
loadDefaultStyleFlagis set toTruethen the layer’s existing style will be reset to the default for the data source.Note
If
loadDefaultStyleFlagisFalsethen the layer’s renderer and legend will be preserved only if the geometry type of the new data source matches the current geometry type of the layer.After setting a new data source callers can test
isValid()to determine whether the new source and provider are valid and ready for use. If setting the new data source fails and the layer returnsFalsetoisValid(), then descriptive errors relating to setting the data source can be retrieved by callingerror().This method was defined in
QgsVectorLayersince 2.10 and was marked as deprecated since 3.2See also
Added in version 3.20.
setDataSource(self, dataSource: Optional[str], baseName: Optional[str], provider: Optional[str], options: QgsDataProvider.ProviderOptions, loadDefaultStyleFlag: bool = False) Updates the data source of the layer.
The
dataSourceargument must specify the new data source string for the layer. The format varies depending on the specified dataproviderin use. SeeQgsDataSourceUriand the documentation for the variousQgsMapLayersubclasses for further details on data source strings.The
baseNameargument specifies the user-visible name to use for the layer. (Seename()orsetName()).The
providerargument is used to specify the unique key of the data provider to use for the layer. This must match one of the values returned byQgsProviderRegistry.instance()->:py:func:~QgsMapLayer.providerList. (SeeproviderType()).The
optionsargument can be used to pass additional layer properties to the new data provider.If
loadDefaultStyleFlagis set toTruethen the layer’s existing style will be reset to the default for the data source.Note
If
loadDefaultStyleFlagisFalsethen the layer’s renderer and legend will be preserved only if the geometry type of the new data source matches the current geometry type of the layer.After setting a new data source callers can test
isValid()to determine whether the new source and provider are valid and ready for use. If setting the new data source fails and the layer returnsFalsetoisValid(), then descriptive errors relating to setting the data source can be retrieved by callingerror().See also
Added in version 3.6.
setDataSource(self, dataSource: Optional[str], baseName: Optional[str], provider: Optional[str], options: QgsDataProvider.ProviderOptions, flags: Union[Qgis.DataProviderReadFlags, Qgis.DataProviderReadFlag]) Updates the data source of the layer.
The
dataSourceargument must specify the new data source string for the layer. The format varies depending on the specified dataproviderin use. SeeQgsDataSourceUriand the documentation for the variousQgsMapLayersubclasses for further details on data source strings.The
baseNameargument specifies the user-visible name to use for the layer. (Seename()orsetName()).The
providerargument is used to specify the unique key of the data provider to use for the layer. This must match one of the values returned byQgsProviderRegistry.instance()->:py:func:~QgsMapLayer.providerList. (SeeproviderType()).The
optionsargument can be used to pass additional layer properties to the new data provider.The
flagsargument specifies provider read flags which control the data provider construction, such asQgsDataProvider.ReadFlag.FlagTrustDataSource,QgsDataProvider.ReadFlag.FlagLoadDefaultStyle, etc.Note
The layer’s renderer and legend will be preserved only if the geometry type of the new data source matches the current geometry type of the layer.
After setting a new data source callers can test
isValid()to determine whether the new source and provider are valid and ready for use. If setting the new data source fails and the layer returnsFalsetoisValid(), then descriptive errors relating to setting the data source can be retrieved by callingerror().See also
Added in version 3.20.
- Parameters:
dataSource (Optional[str])
baseName (Optional[str] = '')
provider (Optional[str] = '')
loadDefaultStyleFlag (bool = False)
- setDataUrl(self, dataUrl: str | None)[source]¶
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setDataUrl instead.- Parameters:
dataUrl (Optional[str])
- setDataUrlFormat(self, dataUrlFormat: str | None)[source]¶
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setDataUrlFormat instead.- Parameters:
dataUrlFormat (Optional[str])
- virtual setDependencies(self, layers: Iterable[QgsMapLayerDependency]) bool[source]¶
Sets the list of dependencies.
See also
- Parameters:
layers (Iterable[QgsMapLayerDependency]) – set of
QgsMapLayerDependency. Only user-defined dependencies will be added- Return type:
bool
- Returns:
Falseif a dependency cycle has been detected
- virtual setExtent(self, rect: QgsRectangle)[source]¶
Sets the extent
- Parameters:
rect (QgsRectangle)
- virtual setExtent3D(self, box: QgsBox3D)[source]¶
Sets the extent
Added in version 3.36.
- Parameters:
box (QgsBox3D)
- setFlags(self, flags: QgsMapLayer.LayerFlags | QgsMapLayer.LayerFlag)[source]¶
Returns the flags for this layer.
Note
Flags are options specified by the user used for the UI but are not preventing any API call. For instance, even if the Removable flag is not set, the layer can still be removed with the API but the action will not be listed in the legend menu.
See also
Added in version 3.4.
- Parameters:
flags (Union[QgsMapLayer.LayerFlags, QgsMapLayer.LayerFlag])
- setId(self, id: str | None) bool[source]¶
Sets the layer’s
id.Returns
Trueif the layer ID was successfully changed, orFalseif it could not be changed (e.g. because the layer is owned by aQgsProjectorQgsMapLayerStore).Warning
It is the caller’s responsibility to ensure that the layer ID is unique in the desired context. Generally this method should not be called, and the auto generated ID should be used instead.
Warning
This method should not be called on layers which already belong to a
QgsProjectorQgsMapLayerStore.See also
See also
Added in version 3.38.
- Parameters:
id (Optional[str])
- Return type:
bool
- setKeywordList(self, keywords: str | None)[source]¶
Sets the keyword list of the layerused by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setKeywordList instead.- Parameters:
keywords (Optional[str])
- virtual setLayerOrder(self, layers: Iterable[str | None])[source]¶
Reorders the previously selected sublayers of this layer from bottom to top. (Useful for providers that manage their own layers, such as WMS).
- Parameters:
layers (Iterable[Optional[str]])
- setLegend(self, legend: QgsMapLayerLegend | None)[source]¶
Assign a legend controller to the map layer. The object will be responsible for providing legend items.
- Parameters:
legend (Optional[QgsMapLayerLegend]) – Takes ownership of the object. Can be
None.
- setLegendPlaceholderImage(self, imgPath: str | None)[source]¶
Set placeholder image for legend. If the string is empty, a generated legend will be shown.
- Parameters:
imgPath (Optional[str]) – file path to the placeholder image
Added in version 3.22.
- setLegendUrl(self, legendUrl: str | None)[source]¶
Sets the URL for the layer’s legend.
Deprecated since version 3.44: Use
serverProperties()->:py:func:~QgsMapLayer.setLegendUrl instead.- Parameters:
legendUrl (Optional[str])
- setLegendUrlFormat(self, legendUrlFormat: str | None)[source]¶
Sets the format for a URL based layer legend.
Deprecated since version 3.44: Use
serverProperties()->:py:func:~QgsMapLayer.setLegendUrlFormat instead.- Parameters:
legendUrlFormat (Optional[str])
- setMapTipTemplate(self, mapTipTemplate: str | None)[source]¶
The mapTip is a pretty, html representation for feature information.
It may also contain embedded expressions.
Added in version 3.30.
- Parameters:
mapTipTemplate (Optional[str])
- setMapTipsEnabled(self, enabled: bool)[source]¶
Enable or disable map tips for this layer
- Parameters:
enabled (bool) – Whether map tips are enabled for this layer
Added in version 3.32.
- setMaximumScale(self, scale: float)[source]¶
Sets the maximum map
scale(i.e. most “zoomed in” scale) at which the layer will be visible. Thescalevalue indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Ascaleof 0 indicates no maximum scale visibility.Note
Scale based visibility is only used if
setScaleBasedVisibility()is set toTrue.See also
See also
See also
- Parameters:
scale (float)
- virtual setMetadata(self, metadata: QgsLayerMetadata)[source]¶
Sets the layer’s
metadatastore.See also
See also
- Parameters:
metadata (QgsLayerMetadata)
- setMetadataUrl(self, metaUrl: str | None)[source]¶
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request. MetadataUrl is a a link to the detailed, standardized metadata about the data. Since QGIS 3.22, it edits the first metadata URL link.
See also
Deprecated since version 3.22.
- Parameters:
metaUrl (Optional[str])
- setMetadataUrlFormat(self, metaUrlFormat: str | None)[source]¶
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request. MetadataUrlType indicates how the metadata is structured. Since QGIS 3.22, it edits the first metadata URL format.
See also
Deprecated since version 3.22.
- Parameters:
metaUrlFormat (Optional[str])
- setMetadataUrlType(self, metaUrlType: str | None)[source]¶
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType indicates the standard to which the metadata complies. Since QGIS 3.22, it edits the first metadata URL type.
See also
Deprecated since version 3.22.
- Parameters:
metaUrlType (Optional[str])
- setMinimumScale(self, scale: float)[source]¶
Sets the minimum map
scale(i.e. most “zoomed out” scale) at which the layer will be visible. Thescalevalue indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Ascaleof 0 indicates no minimum scale visibility.Note
Scale based visibility is only used if
setScaleBasedVisibility()is set toTrue.See also
See also
See also
- Parameters:
scale (float)
- setName(self, name: str | None)[source]¶
Set the display
nameof the layer.See also
- Parameters:
name (Optional[str])
- virtual setOpacity(self, opacity: float)[source]¶
Sets the
opacityfor the layer, whereopacityis a value between 0 (totally transparent) and 1.0 (fully opaque).See also
See also
Note
Prior to QGIS 3.18, this method was available for vector layers only
Added in version 3.18.
- Parameters:
opacity (float)
- setOriginalXmlProperties(self, originalXmlProperties: str | None)[source]¶
Sets the original XML properties for the layer to
originalXmlPropertiesThe storage format for the XML is qlr
Added in version 3.6.
- Parameters:
originalXmlProperties (Optional[str])
- setProviderType(self, providerType: str | None)[source]¶
Sets the
providerType(provider key)- Parameters:
providerType (Optional[str])
- setRefreshOnNofifyMessage(self, message: str | None)[source]¶
Set the notification message that triggers repaint If refresh on notification is enabled, the notification will triggerRepaint only if the notification message is equal to:param message:
- Parameters:
message (Optional[str])
- setRefreshOnNotifyEnabled(self, enabled: bool)[source]¶
Set whether provider notification is connected to triggerRepaint
- Parameters:
enabled (bool)
- setRenderer3D(self, renderer: QgsAbstract3DRenderer | None)[source]¶
Sets 3D renderer for the layer. Takes ownership of the renderer.
- Parameters:
renderer (Optional[QgsAbstract3DRenderer])
- setScaleBasedVisibility(self, enabled: bool)[source]¶
Sets whether scale based visibility is enabled for the layer.
- Parameters:
enabled (bool) – set to
Trueto enable scale based visibility
See also
See also
See also
- setShortName(self, shortName: str | None)[source]¶
Sets the short name of the layer used by QGIS Server to identify the layer.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setShortName instead.- Parameters:
shortName (Optional[str])
- virtual setSubLayerVisibility(self, name: str | None, visible: bool)[source]¶
Set the visibility of the given sublayer name.
- Parameters:
name (Optional[str]) – sublayer name
visible (bool) – sublayer visibility
- setTitle(self, title: str | None)[source]¶
Sets the title of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.setTitle instead.- Parameters:
title (Optional[str])
- abstract setTransformContext(self, transformContext: QgsCoordinateTransformContext)[source]¶
Sets the coordinate transform context to
transformContextAdded in version 3.8.
- Parameters:
transformContext (QgsCoordinateTransformContext)
- setVerticalCrs(self, crs: QgsCoordinateReferenceSystem)[source]¶
Sets the layer’s vertical coordinate reference system.
The
verticalCrsChanged()signal will be raised if the vertical CRS is changed.Note
If the layer
crs()is a compound CRS, then the CRS returned forverticalCrs()will be the vertical component ofcrs(). Otherwise it will be the value explicitly set by this call.- Parameters:
crs (
QgsCoordinateReferenceSystem) -> (bool) – the vertical CRS- Returns:
Trueif vertical CRS was successfully seterrorMessage: a descriptive message if the vertical CRS could not be set
See also
See also
Added in version 3.38.
- shortName(self) str[source]¶
Returns the short name of the layer used by QGIS Server to identify the layer.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.shortName instead.- Return type:
str
- source(self) str[source]¶
Returns the source for the layer. This source may contain usernames, passwords and other sensitive information.
See also
- Return type:
str
- signal statusChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal styleChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal styleLoaded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- styleManager(self) QgsMapLayerStyleManager | None[source]¶
Gets access to the layer’s style manager. Style manager allows switching between multiple styles.
- Return type:
Optional[QgsMapLayerStyleManager]
- virtual styleURI(self) str[source]¶
Retrieve the style URI for this layer (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- Return type:
str
- Returns:
a string with the style file name
See also
See also
- virtual subLayers(self) List[str][source]¶
Returns the sublayers of this layer. (Useful for providers that manage their own layers, such as WMS).
- Return type:
List[str]
- virtual supportsEditing(self) bool[source]¶
Returns whether the layer supports editing or not.
- Return type:
bool
- Returns:
Falseif the layer is read only or the data provider has no editing capabilities.
Note
default implementation returns
False.Added in version 3.22.
- virtual temporalProperties(self) QgsMapLayerTemporalProperties | None[source]¶
Returns the layer’s temporal properties. This may be
None, depending on the layer type.Added in version 3.14.
- Return type:
Optional[QgsMapLayerTemporalProperties]
- virtual timestamp(self) QDateTime[source]¶
Time stamp of data source in the moment when data/metadata were loaded by provider
- Return type:
QDateTime
- title(self) str[source]¶
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Deprecated since version 3.38: Use
serverProperties()->:py:func:~QgsMapLayer.title instead.- Return type:
str
- transformContext(self) QgsCoordinateTransformContext[source]¶
Returns the layer data provider coordinate transform context or a default transform context if the layer does not have a valid data provider.
Added in version 3.8.
- Return type:
- trigger3DUpdate(self)[source]¶
Will advise any 3D maps that this layer requires to be updated in the scene. Will emit a
request3DUpdate()signal.Added in version 3.18.
- triggerRepaint(self, deferredUpdate: bool = False)[source]¶
Will advise the map canvas (and any other interested party) that this layer requires to be repainted. Will emit a
repaintRequested()signal. IfdeferredUpdateisTruethen the layer will only be repainted when the canvas is next re-rendered, and will not trigger any canvas redraws itself.Note
in 2.6 function moved from vector/raster subclasses to QgsMapLayer
- Parameters:
deferredUpdate (bool = False)
- type(self) Qgis.LayerType[source]¶
Returns the type of the layer.
- Return type:
- undoStack(self) QUndoStack | None[source]¶
Returns pointer to layer’s undo stack
- Return type:
Optional[QUndoStack]
- undoStackStyles(self) QUndoStack | None[source]¶
Returns pointer to layer’s style undo stack
- Return type:
Optional[QUndoStack]
- verticalCrs(self) QgsCoordinateReferenceSystem[source]¶
Returns the layer’s vertical coordinate reference system.
If the layer
crs()is a compound CRS, then the CRS returned will be the vertical component ofcrs(). Otherwise it will be the value explicitly set by a call tosetVerticalCrs().The returned CRS will be invalid if the layer has no vertical CRS.
Note
Consider also using
crs3D(), which will return a CRS which takes into account bothcrs()andverticalCrs().See also
See also
See also
Added in version 3.38.
- Return type:
- signal verticalCrsChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- wgs84Extent(self, forceRecalculate: bool = False) QgsRectangle[source]¶
Returns the WGS84 extent (EPSG:4326) of the layer according to ReadFlag.FlagTrustLayerMetadata. If that flag is activated, then the WGS84 extent read in the qgs project is returned. Otherwise, the actual WGS84 extent is returned.
- Parameters:
forceRecalculate (bool = False) – True to return the current WGS84 extent whatever the read flags
Added in version 3.20.
- Return type:
- signal willBeDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- writeCommonStyle(self, layerElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)[source]¶
Write style data common to all layer types
- Parameters:
layerElement (QDomElement)
document (QDomDocument)
context (QgsReadWriteContext)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)
- writeCustomProperties(self, layerNode: QDomNode, doc: QDomDocument)[source]¶
Write custom properties to project file.
- Parameters:
layerNode (QDomNode)
doc (QDomDocument)
- writeLayerXml(self, layerElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]¶
Stores state in DOM node
- Parameters:
layerElement (QDomElement) – is a DOM element corresponding to
maplayertagdocument (QDomDocument) – is a the DOM document being written
context (QgsReadWriteContext) – reading context (e.g. for conversion between relative and absolute paths)
Note
The DOM node corresponds to a DOM document project file XML element to be written by
QgsProject.This, in turn, calls
writeXml()(and then writeSymbology), which is over-rideable by sub-classes so that they can write their own specific state to the given DOM node.Invoked by
QgsProject.write().- Return type:
bool
- Returns:
Trueif successful
- virtual writeStyle(self, node: QDomNode, doc: QDomDocument, errorMessage: str | None, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool[source]¶
Write just the symbology information for the layer into the document
- Parameters:
node (QDomNode) – the node that will have the style element added to it.
doc (QDomDocument) – the document that will have the QDomNode added.
errorMessage (Optional[str]) – reference to string that will be updated with any error messages
context (QgsReadWriteContext) – writing context (used for transform from absolute to relative paths)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be written
- Return type:
bool
- Returns:
Truein case of success.
Note
To be implemented in subclasses. Default implementation does nothing and returns
False.Note
There is a confusion of terms with the GUI. This method actually writes what is known as the symbology in the application.
- writeStyleManager(self, layerNode: QDomNode, doc: QDomDocument)[source]¶
Write style manager’s configuration (if exists). To be called by subclasses.
- Parameters:
layerNode (QDomNode)
doc (QDomDocument)
- abstract writeSymbology(self, node: QDomNode, doc: QDomDocument, errorMessage: str | None, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool[source]¶
Write the style for the layer into the document provided.
- Parameters:
node (QDomNode) – the node that will have the style element added to it.
doc (QDomDocument) – the document that will have the QDomNode added.
errorMessage (Optional[str]) – reference to string that will be updated with any error messages
context (QgsReadWriteContext) – writing context (used for transform from absolute to relative paths)
categories (Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories) – the style categories to be written
Note
There is a confusion of terms with the GUI. This method actually writes what is called a style in the application.
- Return type:
bool
- Returns:
Truein case of success.
- virtual writeXml(self, layer_node: QDomNode, document: QDomDocument, context: QgsReadWriteContext) bool[source]¶
Called by
writeLayerXML(), used by children to write state specific to them to project files.- Parameters:
layer_node (QDomNode)
document (QDomDocument)
context (QgsReadWriteContext)
- Return type:
bool