Class: QgsVectorLayerTemporalProperties

Implementation of map layer temporal properties for vector layers.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.core.QgsVectorLayerTemporalProperties

Base classes

QgsMapLayerTemporalProperties

Base class for storage of map layer temporal properties.

QgsTemporalProperty

Base class for temporal property.

QObject

Enums

TemporalMode

alias of VectorTemporalMode

Methods

accumulateFeatures

Returns True if features will be accumulated over time (i.e. all features which occur before or within the map's temporal range should be rendered).

createFilterString

Creates a QGIS expression filter string for filtering features within the specified context to those within the specified time range.

durationField

Returns the name of the duration field, which contains the duration of the event.

durationUnits

Returns the units of the event's duration.

endExpression

Returns the expression for the end time for the feature's time spans.

endField

Returns the name of the end datetime field, which contains the end time for the feature's time spans.

fixedDuration

Returns the fixed duration length, which contains the duration of the event.

fixedTemporalRange

Returns the fixed temporal range for the layer.

guessDefaultsFromFields

Attempts to setup the temporal properties by scanning a set of fields and looking for standard naming conventions (e.g. "begin_date").

limitMode

Returns the temporal limit mode (to include or exclude begin/end limits).

mode

Returns the temporal properties mode.

setAccumulateFeatures

Sets whether features will be accumulated over time (i.e. all features which occur before or within the map's temporal range should be rendered).

setDurationField

Sets the name of the duration field, which contains the duration of the event.

setDurationUnits

Sets the units of the event's duration.

setEndExpression

Sets the expression to use for the end time for the feature's time spans.

setEndField

Sets the name of the end datetime field, which contains the end time for the feature's time spans.

setFixedDuration

Sets the fixed event duration, which contains the duration of the event.

setFixedTemporalRange

Sets a temporal range to apply to the whole layer.

setLimitMode

Sets the temporal limit mode (to include or exclude begin/end limits).

setMode

Sets the temporal properties mode.

setStartExpression

Sets the expression to use for the start time for the feature's time spans.

setStartField

Sets the name of the start datetime field, which contains the start time for the feature's time spans.

startExpression

Returns the expression for the start time for the feature's time spans.

startField

Returns the name of the start datetime field, which contains the start time for the feature's time spans.

class qgis.core.QgsVectorLayerTemporalProperties[source]

Bases: QgsMapLayerTemporalProperties

__init__(parent: QObject | None = None, enabled: bool = False)

Constructor for QgsVectorLayerTemporalProperties, with the specified parent object.

The enabled argument specifies whether the temporal properties are initially enabled or not (see isActive()).

Parameters:
  • parent (Optional[QObject] = None)

  • enabled (bool = False)

TemporalMode

alias of VectorTemporalMode

accumulateFeatures(self) bool[source]

Returns True if features will be accumulated over time (i.e. all features which occur before or within the map’s temporal range should be rendered).

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeInstantFromField

Return type:

bool

createFilterString(self, context: QgsVectorLayerTemporalContext, range: QgsDateTimeRange) str[source]

Creates a QGIS expression filter string for filtering features within the specified context to those within the specified time range.

The returned expression string considers the mode() and other related settings (such as startField()) when building the filter string.

Warning

Note that ModeFixedTemporalRange is intentional NOT handled by this method and if mode() is ModeFixedTemporalRange then an empty string will be returned. Use isVisibleInTemporalRange() when testing whether features from a layer set to the ModeFixedTemporalRange should ALL be filtered out.

Parameters:
Return type:

str

durationField(self) str[source]

Returns the name of the duration field, which contains the duration of the event.

Units are specified by durationUnits()

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndDurationFromFields

See also

durationUnits()

Return type:

str

durationUnits(self) Qgis.TemporalUnit[source]

Returns the units of the event’s duration.

Return type:

Qgis.TemporalUnit

endExpression(self) str[source]

Returns the expression for the end time for the feature’s time spans.

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndEndFromExpressions

Return type:

str

endField(self) str[source]

Returns the name of the end datetime field, which contains the end time for the feature’s time spans.

See also

setEndField()

See also

startField()

Return type:

str

fixedDuration(self) float[source]

Returns the fixed duration length, which contains the duration of the event.

Units are specified by durationUnits()

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeInstantFromField

See also

durationUnits()

Return type:

float

fixedTemporalRange(self) QgsDateTimeRange

Returns the fixed temporal range for the layer.

Warning

To be used only when mode() is QgsVectorLayerTemporalProperties.ModeFixedTemporalRange

Return type:

QgsDateTimeRange

guessDefaultsFromFields(self, fields: QgsFields)[source]

Attempts to setup the temporal properties by scanning a set of fields and looking for standard naming conventions (e.g. “begin_date”).

Parameters:

fields (QgsFields)

limitMode(self) Qgis.VectorTemporalLimitMode[source]

Returns the temporal limit mode (to include or exclude begin/end limits).

See also

setLimitMode()

Added in version 3.22.

Return type:

Qgis.VectorTemporalLimitMode

mode(self) Qgis.VectorTemporalMode[source]

Returns the temporal properties mode.

See also

setMode()

Return type:

Qgis.VectorTemporalMode

setAccumulateFeatures(self, accumulate: bool)[source]

Sets whether features will be accumulated over time (i.e. all features which occur before or within the map’s temporal range should be rendered).

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeInstantFromField

Parameters:

accumulate (bool)

setDurationField(self, field: str | None)[source]

Sets the name of the duration field, which contains the duration of the event.

Units are specified by setDurationUnits()

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndDurationFromFields

See also

durationField()

Parameters:

field (Optional[str])

setDurationUnits(self, units: Qgis.TemporalUnit)[source]

Sets the units of the event’s duration.

See also

durationUnits()

Parameters:

units (Qgis.TemporalUnit)

setEndExpression(self, endExpression: str | None)[source]

Sets the expression to use for the end time for the feature’s time spans.

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndEndFromExpressions

See also

endExpression()

Parameters:

endExpression (Optional[str])

setEndField(self, field: str | None)[source]

Sets the name of the end datetime field, which contains the end time for the feature’s time spans.

See also

endField()

See also

setStartField()

Parameters:

field (Optional[str])

setFixedDuration(self, duration: float)[source]

Sets the fixed event duration, which contains the duration of the event.

Units are specified by setDurationUnits()

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeInstantFromField

See also

fixedDuration()

Parameters:

duration (float)

setFixedTemporalRange(self, range: QgsDateTimeRange)[source]

Sets a temporal range to apply to the whole layer. All features from the layer will be rendered whenever the current datetime range of a render context intersects the specified range.

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFixedTemporalRange

Parameters:

range (QgsDateTimeRange)

setLimitMode(self, mode: Qgis.VectorTemporalLimitMode)[source]

Sets the temporal limit mode (to include or exclude begin/end limits).

See also

limitMode()

Added in version 3.22.

Parameters:

mode (Qgis.VectorTemporalLimitMode)

setMode(self, mode: Qgis.VectorTemporalMode)[source]

Sets the temporal properties mode.

See also

mode()

Parameters:

mode (Qgis.VectorTemporalMode)

setStartExpression(self, expression: str | None)[source]

Sets the expression to use for the start time for the feature’s time spans.

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndEndFromExpressions

Parameters:

expression (Optional[str])

setStartField(self, field: str | None)[source]

Sets the name of the start datetime field, which contains the start time for the feature’s time spans.

If mode() is ModeFeatureDateTimeInstantFromField, then this field represents both the start AND end times.

See also

startField()

See also

setEndField()

Parameters:

field (Optional[str])

startExpression(self) str[source]

Returns the expression for the start time for the feature’s time spans.

Warning

This setting is only effective when mode() is QgsVectorLayerTemporalProperties.ModeFeatureDateTimeStartAndEndFromExpressions

See also

endExpression()

Return type:

str

startField(self) str[source]

Returns the name of the start datetime field, which contains the start time for the feature’s time spans.

If mode() is ModeFeatureDateTimeInstantFromField, then this field represents both the start AND end times.

See also

setStartField()

See also

endField()

Return type:

str