Subgroup: Raster

Class: QgsRasterDataProvider

class qgis.core.QgsRasterDataProvider

Bases: qgis._core.QgsDataProvider, qgis._core.QgsRasterInterface

Base class for raster data providers.

Methods

appendError
bandCount Get number of bands
bandOffset Read band offset for raster value
bandScale Read band scale for raster value
bandStatistics Get band statistics.
block Read block of data using given extent and size.
blockSignals
buildPyramidList Accessor for the raster layers pyramid list.
buildPyramids Create pyramid overviews
capabilities Returns a bitmask containing the supported capabilities
capabilitiesString Returns the above in friendly format.
childEvent
children
clone
colorInterpretation Returns data type for the band specified by number
colorInterpretationName
colorName
colorTable
connectNotify
copyBaseSettings Copy member variables from other raster data provider.
create Creates a new dataset with mDataSourceURI
crs Returns the coordinate system for the data source.
cumulativeCut Find values for cumulative pixel count cut.
customEvent
dataSourceUri Get the data source specification.
dataTimestamp Current time stamp of data source
dataType Returns data type for the band specified by number
dataTypeSize
deleteLater
description Return description
disconnect
disconnectNotify
dpi Returns the dpi of the output device.
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
enterUpdateMode Enter update mode.
error Get current status error.
event
eventFilter
extent
fileRasterFilters Return raster file filter string
fileVectorFilters Return vector file filter string
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
generateBandName helper function to create zero padded band names
getLegendGraphicFetcher Get an image downloader for the raster legend
hasHistogram Returns true if histogram is available (cached, already calculated)
hasPyramids Returns true if raster has at least one populated histogram.
hasStatistics Returns true if histogram is available (cached, already calculated).
histogram Get histogram.
htmlMetadata Get metadata in a format suitable for feeding directly into a subset of the GUI raster properties “Metadata” tab.
identify
identifyFormatFromName
identifyFormatLabel
identifyFormatName
identifyFormatToCapability
inherits
initHistogram
initStatistics
input Current input
installEventFilter
invalidateConnections Invalidate connections corresponding to specified name
isEditable Checks whether the provider is in editing mode, i.e.
isSignalConnected
isValid Returns true if this is a valid layer.
isWidgetType
isWindowType
killTimer
lastError Returns the verbose error text for the last error in this provider
lastErrorFormat Returns the format of the error text for the last error in this provider
lastErrorTitle Returns the caption error text for the last error in this provider
leaveUpdateMode Leave update mode.
metaObject
moveToThread
name Return a provider name
objectName
on Is on/off
parent
property
providerProperty Get the current value of a certain provider property.
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
pyramidResamplingMethods Returns a list of pyramid resampling method name and label pairs
readXml Sets base class members from xml.
receivers
reload Reload data (data could change)
reloadData Reloads the data from the source.
remove Remove dataset
removeEventFilter
sender
senderSignalIndex
setDataSourceUri Set the data source specification.
setDpi Sets the output device resolution.
setEditable Turns on/off editing mode of the provider.
setError
setInput It makes no sense to set input on provider */
setLayerOrder Reorder the list of layer names to be rendered by this provider
setListening Set whether the provider will listen to datasource notifications If set, the provider will issue notify signals.
setNoDataValue Set no data value on created dataset
setObjectName
setOn Set on/off
setParent
setProperty
setProviderProperty Allows setting arbitrary properties on the provider.
setSubLayerVisibility Set the visibility of the given sublayer name
setSubsetString Set the subset string used to create a subset of features in the layer.
setUri Set the data source specification.
setUseSourceNoDataValue Set source nodata value usage
setUserNoDataValue
signalsBlocked
sourceDataType Returns source data type for the band specified by number,
sourceHasNoDataValue Return true if source band has no data value
sourceInput Get source / raw input, the first in pipe, usually provider.
sourceNoDataValue Value representing no data value.
startTimer
stepHeight Step height for raster iterations.
stepWidth Step width for raster iterations.
subLayerCount return the number of layers for the current data source
subLayerStyles Sub-layer styles for each sub-layer handled by this provider,
subLayers Returns the sublayers of this layer - useful for providers that manage
subsetString Returns the subset definition string (typically sql) currently in use by the layer and used by the provider to limit the feature set.
supportsLegendGraphic Returns whether the provider supplies a legend graphic
supportsSubsetString Returns true if the provider supports setting of subset strings.
thread
timerEvent
timestamp Time stamp of data source in the moment when data/metadata were loaded by provider
tr
updateExtents Update the extents of the layer.
uri Get the data source specification.
useSourceNoDataValue Get source nodata value usage
userNoDataValues Get list of user no data value ranges
userNoDataValuesContains Returns true if user no data contains value
validateCreationOptions Validates creation options for a specific dataset and destination format.
validatePyramidsConfigOptions Validates pyramid creation options for a specific dataset and destination format
write
writeBlock Writes pixel data from a raster block into the provider data source.
writeXml Write base class members to xml.
xBlockSize Get block size
xSize Get raster size
yBlockSize
ySize

Attributes

BuildPyramids
Create
CustomData
Database
Dir
EvaluateDefaultValues
File
Identify
IdentifyFeature
IdentifyHtml
IdentifyText
IdentifyValue
Net
NoCapabilities
NoDataCapabilities
Remove
SUBLAYER_SEPARATOR
Size
dataChanged This is emitted whenever an asynchronous operation has finished
destroyed destroyed(self, QObject = None) [signal]
fullExtentCalculated This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer, and its event has been received by this provider.
notify Emitted when datasource issues a notification
objectNameChanged objectNameChanged(self, str) [signal]
staticMetaObject
statusChanged Emit a message to be displayed on status bar, usually used by network providers (WMS,WCS)
appendError()
bandOffset(self, bandNo: int) → float

Read band offset for raster value

New in version 2.3.

bandScale(self, bandNo: int) → float

Read band scale for raster value

New in version 2.3.

block(self, bandNo: int, boundingBox: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback = None) → QgsRasterBlock

Read block of data using given extent and size.

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

Accessor for the raster layers pyramid list.

Parameters:overviewList – used to construct the pyramid list (optional), when empty the list is defined by the provider.

A pyramid list defines the POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers ACTUALLY exists you need to look at the existsFlag member in each struct stored in the list.

buildPyramids(self, pyramidList: object, resamplingMethod: str = '', format: QgsRaster.RasterPyramidsFormat = QgsRaster.PyramidsGTiff, configOptions: Iterable[str] = [], feedback: QgsRasterBlockFeedback = None) → str

Create pyramid overviews

childEvent()
clone(self) → QgsRasterInterface
colorInterpretation(self, bandNo: int) → int

Returns data type for the band specified by number

colorInterpretationName(self, bandNo: int) → str
colorName(self, colorInterpretation: int) → str
colorTable(self, bandNo: int) → List[QgsColorRampShader.ColorRampItem]
connectNotify()
copyBaseSettings(self, other: QgsRasterDataProvider)

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

create(providerKey: str, uri: str, format: str, nBands: int, type: Qgis.DataType, width: int, height: int, crs: QgsCoordinateReferenceSystem, createOptions: Iterable[str] = []) → Tuple[QgsRasterDataProvider, float]

Creates a new dataset with mDataSourceURI

customEvent()
dataTimestamp(self) → QDateTime

Current time stamp of data source

dataType(self, bandNo: int) → Qgis.DataType

Returns data type for the band specified by number

disconnectNotify()
dpi(self) → int

Returns the dpi of the output device.

extent(self) → QgsRectangle
getLegendGraphicFetcher(self, mapSettings: QgsMapSettings) → QgsImageFetcher

Get an image downloader for the raster legend

Parameters:mapSettings – map settings for legend providers supporting

contextual legends.

Returns:a download handler or null if the provider does not support

legend at all. Ownership of the returned object is transferred to caller.

New in version 2.8.

hasPyramids(self) → bool

Returns true if raster has at least one populated histogram.

htmlMetadata(self) → str

Get metadata in a format suitable for feeding directly into a subset of the GUI raster properties “Metadata” tab.

identify(self, point: QgsPointXY, format: QgsRaster.IdentifyFormat, boundingBox: QgsRectangle = QgsRectangle(), width: int = 0, height: int = 0, dpi: int = 96) → QgsRasterIdentifyResult
identifyFormatFromName(formatName: str) → QgsRaster.IdentifyFormat
identifyFormatLabel(format: QgsRaster.IdentifyFormat) → str
identifyFormatName(format: QgsRaster.IdentifyFormat) → str
identifyFormatToCapability(format: QgsRaster.IdentifyFormat) → QgsRasterInterface.Capability
initHistogram()
initStatistics()
isEditable(self) → bool

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()

New in version 3.0.

isSignalConnected()
lastError(self) → str

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.

lastErrorFormat(self) → str

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

lastErrorTitle(self) → str

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.

pyramidResamplingMethods(providerKey: str) → List[Tuple[str, str]]

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

receivers()
reload(self) → bool

Reload data (data could change)

remove(self) → bool

Remove dataset

sender()
senderSignalIndex()
setDpi(self, dpi: int)

Sets the output device resolution.

setEditable(self, enabled: bool) → bool

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

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()

New in version 3.0.

setError()
setInput(self, input: QgsRasterInterface) → bool

It makes no sense to set input on provider */

setNoDataValue(self, bandNo: int, noDataValue: float) → bool

Set no data value on created dataset

Parameters:
  • bandNo – band number
  • noDataValue – no data value
setUseSourceNoDataValue(self, bandNo: int, use: bool)

Set source nodata value usage

setUserNoDataValue(self, bandNo: int, noData: object)
sourceDataType(self, bandNo: int) → Qgis.DataType

Returns source data type for the band specified by number, source data type may be shorter than dataType

sourceHasNoDataValue(self, bandNo: int) → bool

Return true if source band has no data value

sourceNoDataValue(self, bandNo: int) → float

Value representing no data value.

statusChanged

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

New in version 2.14: [signal]

stepHeight(self) → int

Step height for raster iterations.

See also

stepWidth()

New in version 3.0.

stepWidth(self) → int

Step width for raster iterations.

See also

stepHeight()

New in version 3.0.

subLayers(self) → List[str]

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

supportsLegendGraphic(self) → bool

Returns whether the provider supplies a legend graphic

timerEvent()
timestamp(self) → QDateTime

Time stamp of data source in the moment when data/metadata were loaded by provider

useSourceNoDataValue(self, bandNo: int) → bool

Get source nodata value usage

userNoDataValues(self, bandNo: int) → object

Get list of user no data value ranges

userNoDataValuesContains(self, bandNo: int, value: float) → bool

Returns true if user no data contains value

validateCreationOptions(self, createOptions: Iterable[str], format: str) → str

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

validatePyramidsConfigOptions(self, pyramidsFormat: QgsRaster.RasterPyramidsFormat, configOptions: Iterable[str], fileFormat: str) → str

Validates pyramid creation options for a specific dataset and destination format

Note

used by GDAL provider only

write(self, data: sip.voidptr, band: int, width: int, height: int, xOffset: int, yOffset: int) → bool
writeBlock(self, block: QgsRasterBlock, band: int, xOffset: int = 0, yOffset: int = 0) → bool

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()

Returns:true on success

New in version 3.0.