Class: QgsRasterDataProvider

Base class for raster data providers.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: QgsRasterInterface.bandCount(), QgsDataProvider.crs(), QgsDataProvider.description(), QgsDataProvider.isValid(), lastError(), lastErrorTitle(), QgsDataProvider.name()

Class Hierarchy

Inheritance diagram of qgis.core.QgsRasterDataProvider

Base classes

QgsDataProvider

Abstract base class for spatial data provider implementations.

QObject

QgsRasterInterface

Base class for processing filters like renderers, reprojector, resampler etc.

Enums

ProviderCapability

alias of RasterProviderCapability

ResamplingMethod

alias of RasterResamplingMethod

Abstract Methods

lastError

Returns the verbose error text for the last error in this provider

lastErrorTitle

Returns the caption error text for the last error in this provider

Methods

attributeTable

Returns the (possibly None) attribute table for the specified bandNumber.

colorName

Returns a string color name representation of a color interpretation.

copyBaseSettings

Copy member variables from other raster data provider.

dpi

Returns the dpi of the output device.

hasPyramids

Returns True if raster has at least one existing pyramid.

isProviderResamplingEnabled

Returns whether provider-level resampling is enabled.

maxOversampling

Returns maximum oversampling factor for zoomed-out operations.

readFileBasedAttributeTable

Loads the filesystem-based attribute table for the specified bandNumber from path, optionally reporting any error in errorMessage, returns True on success.

removeAttributeTable

Remove the attribute table for the specified bandNumber.

setAttributeTable

Set the attribute table to attributeTable for the specified bandNumber, if the attributeTable is None any existing attribute table for the specified band will be removed.

setDpi

Sets the output device resolution.

userNoDataValuesContains

Returns True if user no data contains value

writeBlock

Writes pixel data from a raster block into the provider data source.

writeFileBasedAttributeTable

Writes the filesystem-based attribute table for the specified bandNumber to path, optionally reporting any error in errorMessage, returns True on success.

zoomedInResamplingMethod

Returns resampling method for zoomed-in operations.

zoomedOutResamplingMethod

Returns resampling method for zoomed-out operations.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsRasterDataProvider. See the FAQ for more details.

bandDescription

bandOffset

Read band offset for raster value

bandScale

Read band scale for raster value

block

Read block of data using given extent and size.

buildPyramidList

Returns the raster layers pyramid list.

buildPyramids

Creates pyramid overviews.

colorInterpretation

Returns data type for the band specified by number

colorTable

enableProviderResampling

Enable or disable provider-level resampling.

fields

Returns the fields of the raster layer for data providers that expose them, the default implementation returns an empty list.

getLegendGraphicFetcher

Returns a new image downloader for the raster legend.

identify

Identify raster value(s) found on the point position.

ignoreExtents

Returns True if the extents reported by the data provider are not reliable and it's possible that there is renderable content outside of these extents.

isEditable

Checks whether the provider is in editing mode, i.e. raster write operations will be accepted.

lastErrorFormat

Returns the format of the error text for the last error in this provider

maximumTileSize

Returns the maximum tile size in pixels for the data provider.

nativeResolutions

Returns a list of native resolutions if available, i.e. map units per pixel at which the raster source was originally created.

providerCapabilities

Returns flags containing the supported capabilities of the data provider.

readNativeAttributeTable

Reads the native attribute table, optionally reporting any error in errorMessage, returns True on success.

reload

Reload data (data could change)

remove

Remove dataset

sample

Samples a raster value from the specified band found at the point position.

setEditable

Turns on/off editing mode of the provider.

setMaxOversampling

Sets maximum oversampling factor for zoomed-out operations.

setNoDataValue

Set no data value on created dataset

setUseSourceNoDataValue

Sets the source nodata value usage

setUserNoDataValue

setZoomedInResamplingMethod

Set resampling method to apply for zoomed-in operations.

setZoomedOutResamplingMethod

Set resampling method to apply for zoomed-out operations.

sourceHasNoDataValue

Returns True if source band has no data value

sourceNoDataValue

Value representing no data value.

stepHeight

Step height for raster iterations.

stepWidth

Step width for raster iterations.

subLayers

Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS

supportsLegendGraphic

Returns whether the provider supplies a legend graphic

transformCoordinates

Transforms coordinates between source image coordinate space [0..width]x[0..height] and layer coordinate space (georeferenced coordinates).

useSourceNoDataValue

Returns the source nodata value usage

userNoDataValues

Returns a list of user no data value ranges.

validateCreationOptions

Validates creation options for a specific dataset and destination format.

validatePyramidsConfigOptions

Validates pyramid creation options for a specific dataset and destination format

write

Writes into the provider datasource

writeNativeAttributeTable

Static Methods

create

Creates a new dataset with mDataSourceURI

decodeVirtualRasterProviderUri

Decodes the URI returning a struct with all the parameters for QgsVirtualRasterProvider class

encodeVirtualRasterProviderUri

Encodes the URI starting from the struct .

identifyFormatFromName

Converts a string formatName to a raster identify format.

identifyFormatLabel

Converts a raster identify format to a translated string label.

identifyFormatName

Converts a raster identify format to a string name.

identifyFormatToCapability

Converts a raster identify format to a capability.

pyramidResamplingMethods

Returns a list of pyramid resampling method name and label pairs for given provider

Signals

statusChanged

Emit a message to be displayed on status bar, usually used by network providers (WMS,WCS)

Attributes

TransformImageToLayer

TransformLayerToImage

class qgis.core.QgsRasterDataProvider[source]

Bases: QgsDataProvider, QgsRasterInterface

__init__()
__init__(uri: str | None, providerOptions: QgsDataProvider.ProviderOptions = QgsDataProvider.ProviderOptions(), flags: Qgis.DataProviderReadFlags | Qgis.DataProviderReadFlag = Qgis.DataProviderReadFlags())

Constructor for QgsRasterDataProvider.

The uri argument gives a provider-specific uri indicating the underlying data source and it’s parameters.

The options argument specifies generic provider options and since QGIS 3.16 creation flags are specified within the flags value.

Parameters:
ProviderCapabilities

alias of RasterProviderCapabilities

ProviderCapability

alias of RasterProviderCapability

ResamplingMethod

alias of RasterResamplingMethod

TransformImageToLayer = 0
TransformLayerToImage = 1
class TransformType

Bases: int

class VirtualRasterInputLayers

Bases: object

Struct that stores information of the raster used in QgsVirtualRasterProvider for the calculations, this struct is stored in the DecodedUriParameters

Note

used by QgsVirtualRasterProvider only

provider
class VirtualRasterParameters

Bases: object

Struct that stores the information about the parameters that should be given to the QgsVirtualRasterProvider through the QgsRasterDataProvider.DecodedUriParameters

Note

used by QgsVirtualRasterProvider only

formula
height
rInputLayers
width
attributeTable(self, bandNumber: int) QgsRasterAttributeTable | None[source]

Returns the (possibly None) attribute table for the specified bandNumber.

Added in version 3.30.

Parameters:

bandNumber (int)

Return type:

Optional[QgsRasterAttributeTable]

virtual bandDescription(self, bandNumber: int) str[source]
Parameters:

bandNumber (int)

Return type:

str

virtual bandOffset(self, bandNo: int) float[source]

Read band offset for raster value

Parameters:

bandNo (int)

Return type:

float

virtual bandScale(self, bandNo: int) float[source]

Read band scale for raster value

Parameters:

bandNo (int)

Return type:

float

virtual block(self, bandNo: int, boundingBox: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback | None = None) QgsRasterBlock | None[source]

Read block of data using given extent and size.

Parameters:
Return type:

Optional[QgsRasterBlock]

virtual buildPyramidList(self, overviewList: Iterable[int] = []) List[QgsRasterPyramid]

Returns the raster layers pyramid list.

This method returns a list of pyramid layers which are valid for the data provider. The returned list is a complete list of all possible layers, and includes both pyramids layers which currently exist and layers which have not yet been constructed. To know which of the pyramid layers ACTUALLY exists you need to look at the QgsRasterPyramid.getExists() member for each value in the list.

The returned list is suitable for passing to the buildPyramids() method. First, modify the returned list by calling QgsRasterPyramid.setBuild( ``True` )` for every layer you want to create pyramids for, and then pass the modified list to buildPyramids().

Parameters:

overviewList (Iterable[int] = []) – used to construct the pyramid list (optional), when empty the list is defined by the provider.

See also

buildPyramids()

See also

hasPyramids()

Return type:

List[QgsRasterPyramid]

virtual buildPyramids(self, pyramidList: Iterable[QgsRasterPyramid], resamplingMethod: str | None = '', format: Qgis.RasterPyramidFormat = Qgis.RasterPyramidFormat.GeoTiff, configOptions: Iterable[str | None] = [], feedback: QgsRasterBlockFeedback | None = None) str[source]

Creates pyramid overviews.

Parameters:
  • pyramidList (Iterable[QgsRasterPyramid]) – a list of QgsRasterPyramids to create overviews for. The QgsRasterPyramid.setBuild() flag should be set to True for every layer where pyramids are desired.

  • resamplingMethod (Optional[str] = '') – resampling method to use when creating the pyramids. The pyramidResamplingMethods() method can be used to retrieve a list of valid resampling methods available for specific raster data providers.

  • format (Qgis.RasterPyramidFormat = Qgis.RasterPyramidFormat.GeoTiff) – raster pyramid format.

  • configOptions (Iterable[Optional[str]] = []) – optional configuration options which are passed to the specific data provider for use during pyramid creation.

  • feedback (Optional[QgsRasterBlockFeedback] = None) – optional feedback argument for progress reports and cancellation support.

See also

hasPyramids()

Return type:

str

virtual colorInterpretation(self, bandNo: int) Qgis.RasterColorInterpretation[source]

Returns data type for the band specified by number

Parameters:

bandNo (int)

Return type:

Qgis.RasterColorInterpretation

colorName(self, colorInterpretation: Qgis.RasterColorInterpretation) str[source]

Returns a string color name representation of a color interpretation. It is translated since QGIS 3.40

Parameters:

colorInterpretation (Qgis.RasterColorInterpretation)

Return type:

str

virtual colorTable(self, bandNo: int) List[QgsColorRampShader.ColorRampItem]
Parameters:

bandNo (int)

Return type:

List[QgsColorRampShader.ColorRampItem]

copyBaseSettings(self, other: QgsRasterDataProvider)[source]

Copy member variables from other raster data provider. Useful for implementation of clone() method in subclasses

Parameters:

other (QgsRasterDataProvider)

static create(providerKey: str | None, uri: str | None, format: str | None, nBands: int, type: Qgis.DataType, width: int, height: int, crs: QgsCoordinateReferenceSystem, createOptions: Iterable[str | None] = [])[source]

Creates a new dataset with mDataSourceURI

Parameters:
static decodeVirtualRasterProviderUri(uri: str | None)[source]

Decodes the URI returning a struct with all the parameters for QgsVirtualRasterProvider class

Note

used by Virtual Raster Provider only

Note

since QGIS 3.22

Parameters:

uri (Optional[str]) -> (QgsRasterDataProvider.VirtualRasterParameters)

dpi(self) int[source]

Returns the dpi of the output device.

Return type:

int

virtual enableProviderResampling(self, enable: bool) bool[source]

Enable or disable provider-level resampling.

Return type:

bool

Returns:

True if success

Added in version 3.16.

Parameters:

enable (bool)

static encodeVirtualRasterProviderUri(parts: QgsRasterDataProvider.VirtualRasterParameters) str[source]

Encodes the URI starting from the struct .

Note

used by Virtual Raster Provider only

Note

since QGIS 3.22

Parameters:

parts (QgsRasterDataProvider.VirtualRasterParameters)

Return type:

str

virtual fields(self) QgsFields[source]

Returns the fields of the raster layer for data providers that expose them, the default implementation returns an empty list.

Added in version 3.14.

Return type:

QgsFields

virtual getLegendGraphicFetcher(self, mapSettings: QgsMapSettings | None) QgsImageFetcher | None[source]

Returns a new image downloader for the raster legend.

Parameters:

mapSettings (Optional[QgsMapSettings]) – map settings for legend providers supporting contextual legends.

Return type:

Optional[QgsImageFetcher]

Returns:

a download handler or None if the provider does not support legend at all. Ownership of the returned object is transferred to caller.

hasPyramids(self) bool[source]

Returns True if raster has at least one existing pyramid.

The buildPyramidList() method can be used to retrieve additional details about potential and existing pyramid layers.

See also

buildPyramids()

Return type:

bool

virtual identify(self, point: QgsPointXY, format: Qgis.RasterIdentifyFormat, boundingBox: QgsRectangle = QgsRectangle(), width: int = 0, height: int = 0, dpi: int = 96) QgsRasterIdentifyResult[source]

Identify raster value(s) found on the point position. The context parameters extent, width and height are important to identify on the same zoom level as a displayed map and to do effective caching (WCS). If context params are not specified the highest resolution is used. capabilities() may be used to test if format is supported by provider. Values are set to ‘no data’ or empty string if point is outside data source extent.

Parameters:
  • point (QgsPointXY) – coordinates in data source CRS

  • format (Qgis.RasterIdentifyFormat) – result format

  • boundingBox (QgsRectangle = QgsRectangle()) – context bounding box

  • width (int = 0) – context width

  • height (int = 0) – context height

  • dpi (int = 96) – context dpi

Return type:

QgsRasterIdentifyResult

Returns:

QgsRaster.IdentifyFormatValue: map of values for each band, keys are band numbers (from 1). QgsRaster.IdentifyFormatFeature: map of QgsRasterFeatureList for each sublayer QgsRaster.IdentifyFormatHtml: map of HTML strings for each sublayer (WMS). Empty if failed or there are no results.

Note

The arbitraryness of the returned document is enforced by WMS standards up to at least v1.3.0

See also

sample() which is much more efficient for simple “value at point” queries.

static identifyFormatFromName(formatName: str | None) Qgis.RasterIdentifyFormat[source]

Converts a string formatName to a raster identify format.

Parameters:

formatName (Optional[str])

Return type:

Qgis.RasterIdentifyFormat

static identifyFormatLabel(format: Qgis.RasterIdentifyFormat) str[source]

Converts a raster identify format to a translated string label.

Parameters:

format (Qgis.RasterIdentifyFormat)

Return type:

str

static identifyFormatName(format: Qgis.RasterIdentifyFormat) str[source]

Converts a raster identify format to a string name.

Parameters:

format (Qgis.RasterIdentifyFormat)

Return type:

str

static identifyFormatToCapability(format: Qgis.RasterIdentifyFormat) Qgis.RasterInterfaceCapability[source]

Converts a raster identify format to a capability.

Parameters:

format (Qgis.RasterIdentifyFormat)

Return type:

Qgis.RasterInterfaceCapability

virtual ignoreExtents(self) bool[source]

Returns True if the extents reported by the data provider are not reliable and it’s possible that there is renderable content outside of these extents.

Added in version 3.10.0.

Return type:

bool

virtual isEditable(self) bool[source]

Checks whether the provider is in editing mode, i.e. raster write operations will be accepted. By default providers are not editable. Use setEditable() method to enable/disable editing.

See also

setEditable()

See also

writeBlock()

Return type:

bool

isProviderResamplingEnabled(self) bool[source]

Returns whether provider-level resampling is enabled.

Note

Resampling is effective only if zoomedInResamplingMethod() and/or zoomedOutResamplingMethod() return non-nearest resampling.

Added in version 3.16.

Return type:

bool

abstract lastError(self) str[source]

Returns the verbose error text for the last error in this provider

If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure. Interactive users of this provider can then, for example, call a QMessageBox to display the contents.

Return type:

str

virtual lastErrorFormat(self) str[source]

Returns the format of the error text for the last error in this provider

Return type:

str

abstract lastErrorTitle(self) str[source]

Returns the caption error text for the last error in this provider

If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure. Interactive users of this provider can then, for example, call a QMessageBox to display the contents.

Return type:

str

maxOversampling(self) float[source]

Returns maximum oversampling factor for zoomed-out operations.

Added in version 3.16.

Return type:

float

virtual maximumTileSize(self) QSize[source]

Returns the maximum tile size in pixels for the data provider. By default, the maximum tile size is set to QgsRasterIterator.DEFAULT_MAXIMUM_TILE_WIDTH x QgsRasterIterator.DEFAULT_MAXIMUM_TILE_HEIGHT but can be overridden in subclasses (e.g. WMS can retrieve that information from the GetCapabilities document).

Added in version 3.40.

Return type:

QSize

virtual nativeResolutions(self) List[float]

Returns a list of native resolutions if available, i.e. map units per pixel at which the raster source was originally created.

Resolutions are calculated in the provider’s crs().

Added in version 3.8.0.

Return type:

List[float]

virtual providerCapabilities(self) Qgis.RasterProviderCapabilities[source]

Returns flags containing the supported capabilities of the data provider.

Return type:

Qgis.RasterProviderCapabilities

static pyramidResamplingMethods(providerKey: str | None) List[Tuple[str, str]]

Returns a list of pyramid resampling method name and label pairs for given provider

Parameters:

providerKey (Optional[str])

Return type:

List[Tuple[str, str]]

readFileBasedAttributeTable(self, bandNumber: int, path: str | None)[source]

Loads the filesystem-based attribute table for the specified bandNumber from path, optionally reporting any error in errorMessage, returns True on success.

Returns:

True on success

Added in version 3.30.

Parameters:
  • bandNumber (int)

  • path (Optional[str]) -> (bool)

virtual readNativeAttributeTable(self)[source]

Reads the native attribute table, optionally reporting any error in errorMessage, returns True on success. The default implementation does nothing and returns False. Data providers that have NativeRasterAttributeTable provider capability will try to read the native attribute table.

Returns:

True on success

Added in version 3.30.

virtual reload(self) bool[source]

Reload data (data could change)

Return type:

bool

virtual remove(self) bool[source]

Remove dataset

Return type:

bool

removeAttributeTable(self, bandNumber: int)[source]

Remove the attribute table for the specified bandNumber. If the attribute table does not exist this method does nothing.

Added in version 3.30.

Parameters:

bandNumber (int)

virtual sample(self, point: QgsPointXY, band: int, boundingBox: QgsRectangle = QgsRectangle(), width: int = 0, height: int = 0, dpi: int = 96)[source]

Samples a raster value from the specified band found at the point position. The context parameters boundingBox, width and height are important to identify on the same zoom level as a displayed map and to do effective caching (WCS). If context params are not specified the highest resolution is used.

If ok is specified and the point is outside data source extent, or an invalid band number was specified, then ok will be set to False. In this case the function will return a NaN value.

See also

identify() which is much more flexible but considerably less efficient.

Added in version 3.4.

Parameters:
  • point (QgsPointXY)

  • band (int)

  • boundingBox (QgsRectangle = QgsRectangle())

  • width (int = 0)

  • height (int = 0)

  • dpi (int = 96) -> (float)

setAttributeTable(self, bandNumber: int, attributeTable: QgsRasterAttributeTable | None)[source]

Set the attribute table to attributeTable for the specified bandNumber, if the attributeTable is None any existing attribute table for the specified band will be removed.

Note

Ownership of the attribute table is transferred to the provider.

Added in version 3.30.

Parameters:
setDpi(self, dpi: int)[source]

Sets the output device resolution.

Parameters:

dpi (int)

virtual setEditable(self, enabled: bool) bool[source]

Turns on/off editing mode of the provider. When in editing mode, it is possible to overwrite data of the provider using writeBlock() calls.

Return type:

bool

Returns:

True if the switch to/from editing mode was successful

Note

Only some providers support editing mode and even those may fail to turn the underlying data source into editing mode, so it is necessary to check the return value whether the operation was successful.

See also

isEditable()

See also

writeBlock()

Parameters:

enabled (bool)

virtual setMaxOversampling(self, factor: float) bool[source]

Sets maximum oversampling factor for zoomed-out operations.

Return type:

bool

Returns:

True if success

Added in version 3.16.

Parameters:

factor (float)

virtual setNoDataValue(self, bandNo: int, noDataValue: float) bool[source]

Set no data value on created dataset

Parameters:
  • bandNo (int) – band number

  • noDataValue (float) – no data value

Return type:

bool

virtual setUseSourceNoDataValue(self, bandNo: int, use: bool)[source]

Sets the source nodata value usage

Parameters:
  • bandNo (int)

  • use (bool)

virtual setUserNoDataValue(self, bandNo: int, noData: Iterable[QgsRasterRange])[source]
Parameters:
virtual setZoomedInResamplingMethod(self, method: Qgis.RasterResamplingMethod) bool[source]

Set resampling method to apply for zoomed-in operations.

Return type:

bool

Returns:

True if success

Added in version 3.16.

Parameters:

method (Qgis.RasterResamplingMethod)

virtual setZoomedOutResamplingMethod(self, method: Qgis.RasterResamplingMethod) bool[source]

Set resampling method to apply for zoomed-out operations.

Return type:

bool

Returns:

True if success

Added in version 3.16.

Parameters:

method (Qgis.RasterResamplingMethod)

virtual sourceHasNoDataValue(self, bandNo: int) bool[source]

Returns True if source band has no data value

Parameters:

bandNo (int)

Return type:

bool

virtual sourceNoDataValue(self, bandNo: int) float[source]

Value representing no data value.

Parameters:

bandNo (int)

Return type:

float

signal statusChanged[source]

Emit a message to be displayed on status bar, usually used by network providers (WMS,WCS)

virtual stepHeight(self) int[source]

Step height for raster iterations.

See also

stepWidth()

Return type:

int

virtual stepWidth(self) int[source]

Step width for raster iterations.

See also

stepHeight()

Return type:

int

virtual subLayers(self) List[str][source]

Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS

Return type:

List[str]

virtual supportsLegendGraphic(self) bool[source]

Returns whether the provider supplies a legend graphic

Return type:

bool

virtual transformCoordinates(self, point: QgsPoint, type: QgsRasterDataProvider.TransformType) QgsPoint[source]

Transforms coordinates between source image coordinate space [0..width]x[0..height] and layer coordinate space (georeferenced coordinates). Often this transformation is a simple 2D affine transformation (offset and scaling), but rasters with different georeferencing methods like GCPs (ground control points) or RPCs (rational polynomial coefficients) may require a more complex transform.

If the transform fails (input coordinates are outside of the valid range or data provider does not support this functionality), an empty point is returned.

Added in version 3.14.

Parameters:
Return type:

QgsPoint

virtual useSourceNoDataValue(self, bandNo: int) bool[source]

Returns the source nodata value usage

Parameters:

bandNo (int)

Return type:

bool

virtual userNoDataValues(self, bandNo: int) List[QgsRasterRange][source]

Returns a list of user no data value ranges.

Parameters:

bandNo (int)

Return type:

List[QgsRasterRange]

userNoDataValuesContains(self, bandNo: int, value: float) bool[source]

Returns True if user no data contains value

Parameters:
  • bandNo (int)

  • value (float)

Return type:

bool

virtual validateCreationOptions(self, createOptions: Iterable[str | None], format: str | None) str[source]

Validates creation options for a specific dataset and destination format.

Note

used by GDAL provider only

Note

see also validateCreationOptionsFormat() in gdal provider for validating options based on format only

Parameters:
  • createOptions (Iterable[Optional[str]])

  • format (Optional[str])

Return type:

str

virtual validatePyramidsConfigOptions(self, pyramidsFormat: Qgis.RasterPyramidFormat, configOptions: Iterable[str | None], fileFormat: str | None) str[source]

Validates pyramid creation options for a specific dataset and destination format

Note

used by GDAL provider only

Parameters:
Return type:

str

virtual write(self, data: PyQt5.sip.voidptr | None, band: int, width: int, height: int, xOffset: int, yOffset: int) bool[source]

Writes into the provider datasource

Parameters:
  • data (Optional[PyQt5.sip.voidptr])

  • band (int)

  • width (int)

  • height (int)

  • xOffset (int)

  • yOffset (int)

Return type:

bool

writeBlock(self, block: QgsRasterBlock | None, band: int, xOffset: int = 0, yOffset: int = 0) bool[source]

Writes pixel data from a raster block into the provider data source.

This will override previously stored pixel values. It is assumed that cells in the passed raster block are aligned with the cells of the data source. If raster block does not cover the whole area of the data source, only a subset of pixels covered by the raster block will be overwritten. By default, writing of raster data starts from the first cell of the raster - it is possible to set offset in pixels by specifying non-zero xOffset and yOffset values.

Writing is supported only by some data providers. Provider has to be in editing mode in order to allow write operations.

See also

isEditable()

See also

setEditable()

Return type:

bool

Returns:

True on success

Parameters:
  • block (Optional[QgsRasterBlock])

  • band (int)

  • xOffset (int = 0)

  • yOffset (int = 0)

writeFileBasedAttributeTable(self, bandNumber: int, path: str | None)[source]

Writes the filesystem-based attribute table for the specified bandNumber to path, optionally reporting any error in errorMessage, returns True on success.

Returns:

True on success

Note

No checks for Raster Attribute Table validity are performed when saving, it is client code responsibility to handle validation.

Added in version 3.30.

Parameters:
  • bandNumber (int)

  • path (Optional[str]) -> (bool)

virtual writeNativeAttributeTable(self)[source]
zoomedInResamplingMethod(self) Qgis.RasterResamplingMethod[source]

Returns resampling method for zoomed-in operations.

Added in version 3.16.

Return type:

Qgis.RasterResamplingMethod

zoomedOutResamplingMethod(self) Qgis.RasterResamplingMethod[source]

Returns resampling method for zoomed-out operations.

Added in version 3.16.

Return type:

Qgis.RasterResamplingMethod