Subgroup: Layer
Class: QgsLayerMetadata¶
-
class
qgis.core.
QgsLayerMetadata
¶ Bases:
qgis._core.QgsAbstractMetadataBase
Constructor for QgsLayerMetadata.
QgsLayerMetadata(QgsLayerMetadata)
A structured metadata store for a map layer.
QgsLayerMetadata handles storage and management of the metadata for a QgsMapLayer. This class is an internal QGIS format with a common metadata structure, which allows for code to access the metadata properties for layers in a uniform way.
The metadata store is designed to be compatible with the Dublin Core metadata specifications, and will be expanded to allow compatibility with ISO specifications in future releases. However, the QGIS internal schema does not represent a superset of all existing metadata schemas and accordingly conversion from specific metadata formats to QgsLayerMetadata may result in a loss of information.
This class is designed to follow the specifications detailed in the schema definition available at resources/qgis-resource-metadata.xsd within the QGIS source code.
Metadata can be validated through the use of QgsLayerMetadataValidator subclasses. E.g. validating against the native QGIS metadata schema can be performed using QgsNativeMetadataValidator.
New in version 3.0: Methods
addConstraint
Adds an individual constraint to the existing constraints. clone
constraints
Returns a list of constraints associated with using the resource. crs
Returns the coordinate reference system described by the layer’s metadata. encoding
Returns the character encoding of the data in the resource. equals
extent
Returns the spatial and temporal extents associated with the resource. fees
Returns any fees associated with using the resource. licenses
Returns a list of licenses associated with the resource (examples: http://opendefinition.org/licenses/). readFromLayer
Reads the metadata state from a layer
’s custom properties (see QgsMapLayer.customProperty() ).readMetadataXml
rights
Returns a list of attribution or copyright strings associated with the resource. saveToLayer
Saves the metadata to a layer
’s custom properties (see QgsMapLayer.setCustomProperty() ).setConstraints
Sets the list of constraints
associated with using the resource.setCrs
Sets the coordinate reference system for the layer’s metadata. setEncoding
Sets the character encoding
of the data in the resource.setExtent
Sets the spatial and temporal extents associated with the resource. setFees
Sets the fees
associated with using the resource.setLicenses
Sets a list of licenses
associated with the resource.setRights
Sets a list of rights
(attribution or copyright strings) associated with the resource.writeMetadataXml
Signals
Attributes
-
class
Constraint
(constraint: str = '', type: str = '')¶ Bases:
sip.wrapper
Constructor for Constraint.
QgsLayerMetadata.Constraint(QgsLayerMetadata.Constraint)
-
constraint
¶
-
type
¶
-
-
class
Extent
¶ Bases:
sip.wrapper
QgsLayerMetadata.Extent(QgsLayerMetadata.Extent)
-
setSpatialExtents
(self, extents: Iterable[QgsLayerMetadata.SpatialExtent])¶ Sets the spatial
extents
of the resource.See also
-
setTemporalExtents
(self, extents: Iterable[QgsDateTimeRange])¶ Sets the temporal
extents
of the resource.See also
-
spatialExtents
(self) → object¶ Spatial extents of the resource.
See also
-
temporalExtents
(self) → object¶ Temporal extents of the resource. Use QgsDateTimeRange.isInstant() to determine whether the temporal extent is a range or a single point in time. If QgsDateTimeRange.isInfinite() returns true then the temporal extent is considered to be indeterminate and continuous.
See also
-
-
class
SpatialExtent
¶ Bases:
sip.wrapper
QgsLayerMetadata.SpatialExtent(QgsLayerMetadata.SpatialExtent)
-
bounds
¶
-
extentCrs
¶
-
-
addConstraint
(self, constraint: QgsLayerMetadata.Constraint)¶ Adds an individual constraint to the existing constraints.
See also
See also
-
clone
(self) → QgsLayerMetadata¶
-
constraints
(self) → object¶ Returns a list of constraints associated with using the resource.
See also
-
crs
(self) → QgsCoordinateReferenceSystem¶ Returns the coordinate reference system described by the layer’s metadata.
Note that this has no link to
QgsMapLayer.crs()
While in most cases these two systems are likely to be identical, it is possible to have a layer with a different CRS described by it’s accompanying metadata versus the CRS which is actually used to display and manipulate the layer within QGIS. This may be the case when a layer has an incorrect CRS within its metadata and a user has manually overridden the layer’s CRS within QGIS.The CRS described here should either match the CRS from the layer
QgsMapLayer.crs()
or the CRS from the data provider.This property should also match the CRS property used in the spatial extent.
See also
-
encoding
(self) → str¶ Returns the character encoding of the data in the resource. An empty string will be returned if no encoding is set.
See also
-
equals
()¶
-
extent
(self) → QgsLayerMetadata.Extent¶ Returns the spatial and temporal extents associated with the resource.
See also
-
fees
(self) → str¶ Returns any fees associated with using the resource. An empty string will be returned if no fees are set.
See also
-
licenses
(self) → List[str]¶ Returns a list of licenses associated with the resource (examples: http://opendefinition.org/licenses/).
See also
-
readFromLayer
(self, layer: QgsMapLayer)¶ Reads the metadata state from a
layer
’s custom properties (see QgsMapLayer.customProperty() ).See also
-
readMetadataXml
(self, metadataElement: QDomElement) → bool¶
-
rights
(self) → List[str]¶ Returns a list of attribution or copyright strings associated with the resource.
See also
-
saveToLayer
(self, layer: QgsMapLayer)¶ Saves the metadata to a
layer
’s custom properties (see QgsMapLayer.setCustomProperty() ).See also
-
setConstraints
(self, constraints: object)¶ Sets the list of
constraints
associated with using the resource.See also
-
setCrs
(self, crs: QgsCoordinateReferenceSystem)¶ Sets the coordinate reference system for the layer’s metadata.
Note that this has no link to
QgsMapLayer.setCrs()
Setting the layer’s CRS via QgsMapLayer.setCrs() does not affect the layer’s metadata CRS, and changing the CRS from the metadata will not change the layer’s CRS or how it is projected within QGIS.While ideally these two systems are likely to be identical, it is possible to have a layer with a different CRS described by it’s accompanying metadata versus the CRS which is actually used to display and manipulate the layer within QGIS. This may be the case when a layer has an incorrect CRS within its metadata and a user has manually overridden the layer’s CRS within QGIS.
The CRS described here should either match the CRS from the layer
QgsMapLayer.crs()
or the CRS from the data provider.This property should also match the CRS property used in the spatial extent.
See also
-
setEncoding
(self, encoding: str)¶ Sets the character
encoding
of the data in the resource. Use an empty string if no encoding is set.See also
-
setExtent
(self, extent: QgsLayerMetadata.Extent)¶ Sets the spatial and temporal extents associated with the resource.
See also
-
setFees
(self, fees: str)¶ Sets the
fees
associated with using the resource. Use an empty string if no fees are set.See also
-
setLicenses
(self, licenses: Iterable[str])¶ Sets a list of
licenses
associated with the resource. (examples: http://opendefinition.org/licenses/).See also
-
setRights
(self, rights: Iterable[str])¶ Sets a list of
rights
(attribution or copyright strings) associated with the resource.See also
-
writeMetadataXml
(self, metadataElement: QDomElement, document: QDomDocument) → bool¶
-
class