Class: QgsRasterLayerUtils

Contains utility functions for working with raster layers.

Added in version 3.38.

class qgis.core.QgsRasterLayerUtils[source]

Bases: object

static alignRasterExtent(extent: QgsRectangle, origin: QgsPointXY, pixelSizeX: float, pixelSizeY: float) QgsRectangle[source]

Returns a new extent that includes the given extent with corners coordinates aligned to the pixel grid defined by the origin and pixelSizeX and pixelSizeY arguments.

The resulting extent will be expanded if necessary to ensure that its corners fall on pixel boundaries defined by the origin and pixel sizes.

Return type:

QgsRectangle

Returns:

The aligned extent or the original extent if pixel sizes are zero (to avoid division by zero) or if the extent is empty.

Added in version 4.0.

Parameters:
static renderedBandForElevationAndTemporalRange(layer: QgsRasterLayer | None, temporalRange: QgsDateTimeRange, elevationRange: QgsDoubleRange)[source]

Given a raster layer, returns the band which should be used for rendering the layer for a specified temporal and elevation range, respecting any elevation and temporal settings which affect the rendered band.

Parameters:
Returns:

  • Matched band, or -1 if the layer does not have any elevation or temporal settings which affect the rendered band.

  • matched: True if a band matching the temporal and elevation range was found