Class: QgsLayerMetadata¶
-
class
qgis.core.
QgsLayerMetadata
¶ Bases:
QgsAbstractMetadataBase
Constructor for QgsLayerMetadata.
QgsLayerMetadata(
QgsLayerMetadata
)A structured metadata store for a map layer.
QgsLayerMetadata
handles storage and management of the metadata for aQgsMapLayer
. 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.
Methods
Adds an individual constraint to the existing constraints.
- rtype
QgsLayerMetadata
Returns a list of constraints associated with using the resource.
Returns the coordinate reference system described by the layer’s metadata.
Returns the character encoding of the data in the resource.
Tests whether the common metadata fields in this object are equal to
other
.Returns the spatial and temporal extents associated with the resource.
Returns any fees associated with using the resource.
Returns a list of licenses associated with the resource (examples: http://opendefinition.org/licenses/).
Reads the metadata state from a
layer
’s custom properties (see QgsMapLayer.customProperty() ).- param metadataElement
Returns a list of attribution or copyright strings associated with the resource.
Saves the metadata to a
layer
’s custom properties (see QgsMapLayer.setCustomProperty() ).Sets the list of
constraints
associated with using the resource.Sets the coordinate reference system for the layer’s metadata.
Sets the character
encoding
of the data in the resource.Sets the spatial and temporal extents associated with the resource.
Sets the
fees
associated with using the resource.Sets a list of
licenses
associated with the resource.Sets a list of
rights
(attribution or copyright strings) associated with the resource.- param metadataElement
-
class
Constraint
(constraint: str = '', type: str = '')¶ Bases:
sip.wrapper
Constructor for Constraint.
QgsLayerMetadata.Constraint(QgsLayerMetadata.Constraint)
- Parameters
constraint (str = '') –
type (str = '') –
-
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
- Parameters
extents (Iterable[QgsLayerMetadata.SpatialExtent]) –
-
setTemporalExtents
(self, extents: Iterable[QgsDateTimeRange])¶ Sets the temporal
extents
of the resource.See also
- Parameters
extents (Iterable[QgsDateTimeRange]) –
-
spatialExtents
(self) → List[QgsLayerMetadata.SpatialExtent]¶ Spatial extents of the resource.
See also
- Return type
-
temporalExtents
(self) → List[QgsDateTimeRange]¶ 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
- Return type
List[QgsDateTimeRange]
-
-
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
- Parameters
constraint (QgsLayerMetadata.Constraint) –
-
clone
(self) → QgsLayerMetadata¶ - Return type
-
constraints
(self) → List[QgsLayerMetadata.Constraint]¶ Returns a list of constraints associated with using the resource.
See also
- Return type
-
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
- Return type
-
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
- Return type
str
-
equals
(self, other: QgsAbstractMetadataBase) → bool¶ Tests whether the common metadata fields in this object are equal to
other
.Subclasses should utilize this method from their equality operators to test equality of base class members.
New in version 3.2.
-
extent
(self) → QgsLayerMetadata.Extent¶ Returns the spatial and temporal extents associated with the resource.
See also
- Return type
-
fees
(self) → str¶ Returns any fees associated with using the resource. An empty string will be returned if no fees are set.
See also
- Return type
str
-
licenses
(self) → List[str]¶ Returns a list of licenses associated with the resource (examples: http://opendefinition.org/licenses/).
See also
- Return type
List[str]
-
readFromLayer
(self, layer: QgsMapLayer)¶ Reads the metadata state from a
layer
’s custom properties (see QgsMapLayer.customProperty() ).See also
- Parameters
layer (QgsMapLayer) –
-
readMetadataXml
(self, metadataElement: QDomElement) → bool¶ - Parameters
metadataElement (QDomElement) –
- Return type
bool
-
rights
(self) → List[str]¶ Returns a list of attribution or copyright strings associated with the resource.
See also
- Return type
List[str]
-
saveToLayer
(self, layer: QgsMapLayer)¶ Saves the metadata to a
layer
’s custom properties (see QgsMapLayer.setCustomProperty() ).See also
- Parameters
layer (QgsMapLayer) –
-
setConstraints
(self, constraints: Iterable[QgsLayerMetadata.Constraint])¶ Sets the list of
constraints
associated with using the resource.See also
- Parameters
constraints (Iterable[QgsLayerMetadata.Constraint]) –
-
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
- Parameters
crs (QgsCoordinateReferenceSystem) –
-
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
- Parameters
encoding (str) –
-
setExtent
(self, extent: QgsLayerMetadata.Extent)¶ Sets the spatial and temporal extents associated with the resource.
See also
- Parameters
extent (QgsLayerMetadata.Extent) –
-
setFees
(self, fees: str)¶ Sets the
fees
associated with using the resource. Use an empty string if no fees are set.See also
- Parameters
fees (str) –
-
setLicenses
(self, licenses: Iterable[str])¶ Sets a list of
licenses
associated with the resource. (examples: http://opendefinition.org/licenses/).See also
- Parameters
licenses (Iterable[str]) –
-
setRights
(self, rights: Iterable[str])¶ Sets a list of
rights
(attribution or copyright strings) associated with the resource.See also
- Parameters
rights (Iterable[str]) –
-
writeMetadataXml
(self, metadataElement: QDomElement, document: QDomDocument) → bool¶ - Parameters
metadataElement (QDomElement) –
document (QDomDocument) –
- Return type
bool