Class: QgsTemporalUtils

class qgis.core.QgsTemporalUtils

Bases: sip.wrapper

Contains utility methods for working with temporal layers and projects.

Methods

calculateFrameTime

Calculates the frame time for an animation.

calculateTemporalRangeForProject

Calculates the temporal range for a project.

exportAnimation

Exports animation frames by rendering the map to multiple destination images.

class AnimationExportSettings

Bases: sip.wrapper

QgsTemporalUtils.AnimationExportSettings(QgsTemporalUtils.AnimationExportSettings)

animationRange
decorations
fileNameTemplate
frameDuration
outputDirectory
calculateFrameTime(start: Union[QDateTime, datetime.datetime], frame: int, interval: QgsInterval) → QDateTime

Calculates the frame time for an animation.

If the interval original duration is fractional or interval original unit is unknown (QgsUnitTypes.TemporalUnit.TemporalUnknownUnit), then QgsInterval is used to determine the duration of the frame. This uses average durations for months and years.

Otherwise, we use QDateTime to advance by the exact duration of the current month or year. So a time step of 1.5 months will result in a duration of 45 days, but a time step of 1 month will result in a duration that depends upon the number of days in the current month.

Parameters
  • start (Union[QDateTime) – time of the animation

  • frame (int) – number

  • interval (QgsInterval) – duration of the animation

Return type

QDateTime

Returns

The calculated datetime for the frame.

New in version 3.18.

calculateTemporalRangeForProject(project: QgsProject)QgsDateTimeRange

Calculates the temporal range for a project.

This method considers the temporal range available from layers contained within the project and returns the maximal combined temporal extent of these layers.

Parameters

project (QgsProject) –

Return type

QgsDateTimeRange

exportAnimation(mapSettings: QgsMapSettings, settings: QgsTemporalUtils.AnimationExportSettings, feedback: QgsFeedback = None) → Tuple[bool, str]

Exports animation frames by rendering the map to multiple destination images.

The mapSettings argument dictates the overall map settings such as extent and size, while animation and export specific settings are specified via the settings argument.

An optional feedback argument can be used to provide progress reports and cancellation support.

Parameters
Return type

Tuple[bool, str]

Returns

  • True if the export was successful.

  • error: will be set to a descriptive error message if the export fails