Class: QgsRasterContourRenderer

class qgis.core.QgsRasterContourRenderer

Bases: QgsRasterRenderer

Raster renderer that generates contours on the fly for a source raster band.

Added in version 3.14.

QgsRasterContourRenderer(input: Optional[QgsRasterInterface]) Creates a contour renderer

Methods

block

param bandNo:

clone

QgsRasterContourRenderer cannot be copied.

contourIndexInterval

Returns the interval of index contour lines (index contour lines are typical further apart and with a wider line symbol)

contourIndexSymbol

Returns the symbol of index contour lines

contourInterval

Returns the interval of contour lines generation

contourSymbol

Returns the symbol used for contour lines

create

Creates an instance of the renderer based on definition from XML (used by renderer registry)

createLegendNodes

param nodeLayer:

downscale

Returns by how much the renderer will scale down the request to the data provider.

initHistogram

Fill in histogram defaults if not specified

initStatistics

Fill in statistics defaults if not specified

inputBand

Returns the number of the input raster band

renderColorForNodataPixel

Returns the color for the renderer to use to represent nodata pixels.

setContourIndexInterval

Sets the interval of index contour lines (index contour lines are typical further apart and with a wider line symbol)

setContourIndexSymbol

Sets the symbol of index contour lines

setContourInterval

Sets the interval of contour lines generation

setContourSymbol

Sets the symbol used for contour lines.

setDownscale

Sets by how much the renderer will scale down the request to the data provider.

setInputBand

Sets the number of the input raster band

usesBands

rtype:

List[int]

writeXml

param doc:

block(self, bandNo: int, extent: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback | None = None) QgsRasterBlock | None
Parameters:
Return type:

Optional[QgsRasterBlock]

clone(self) QgsRasterContourRenderer | None

QgsRasterContourRenderer cannot be copied. Use clone() instead.

Return type:

Optional[QgsRasterContourRenderer]

contourIndexInterval(self) float

Returns the interval of index contour lines (index contour lines are typical further apart and with a wider line symbol)

Return type:

float

contourIndexSymbol(self) QgsLineSymbol | None

Returns the symbol of index contour lines

Return type:

Optional[QgsLineSymbol]

contourInterval(self) float

Returns the interval of contour lines generation

Return type:

float

contourSymbol(self) QgsLineSymbol | None

Returns the symbol used for contour lines

Return type:

Optional[QgsLineSymbol]

create(elem: QDomElement, input: QgsRasterInterface | None) QgsRasterRenderer | None

Creates an instance of the renderer based on definition from XML (used by renderer registry)

Parameters:
Return type:

Optional[QgsRasterRenderer]

createLegendNodes(self, nodeLayer: QgsLayerTreeLayer | None) List[QgsLayerTreeModelLegendNode]
Parameters:

nodeLayer (Optional[QgsLayerTreeLayer])

Return type:

List[QgsLayerTreeModelLegendNode]

downscale(self) float

Returns by how much the renderer will scale down the request to the data provider. For example, for a raster block 1000x500 with downscale 10, the renderer will request raster 100x50 from provider. Higher downscale makes contour lines more simplified (at the expense of losing some detail). The value of one means there will be no downscaling.

Return type:

float

initHistogram(self, histogram: QgsRasterHistogram, bandNo: int, binCount: int, minimum: Any = Py_None, maximum: Any = Py_None, boundingBox: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False)

Fill in histogram defaults if not specified

Note

the parameters are the same as in histogram()

initStatistics(self, statistics: QgsRasterBandStats, bandNo: int, stats: int = QgsRasterBandStats.All, boundingBox: QgsRectangle = QgsRectangle(), binCount: int = 0)

Fill in statistics defaults if not specified

inputBand(self) int

Returns the number of the input raster band

Return type:

int

renderColorForNodataPixel(self) int

Returns the color for the renderer to use to represent nodata pixels.

Subclasses should use this rather then nodataColor() to determine the color to use for nodata pixels during an actual rendering operation.

Added in version 3.10.

setContourIndexInterval(self, interval: float)

Sets the interval of index contour lines (index contour lines are typical further apart and with a wider line symbol)

Parameters:

interval (float)

setContourIndexSymbol(self, symbol: QgsLineSymbol | None)

Sets the symbol of index contour lines

Parameters:

symbol (Optional[QgsLineSymbol])

setContourInterval(self, interval: float)

Sets the interval of contour lines generation

Parameters:

interval (float)

setContourSymbol(self, symbol: QgsLineSymbol | None)

Sets the symbol used for contour lines. Takes ownership of the passed symbol

Parameters:

symbol (Optional[QgsLineSymbol])

setDownscale(self, scale: float)

Sets by how much the renderer will scale down the request to the data provider.

See also

downscale()

Parameters:

scale (float)

setInputBand(self, band: int)

Sets the number of the input raster band

Parameters:

band (int)

usesBands(self) List[int]
Return type:

List[int]

writeXml(self, doc: QDomDocument, parentElem: QDomElement)
Parameters:
  • doc (QDomDocument)

  • parentElem (QDomElement)