QgsHillshadeRenderer class

A renderer for generating live hillshade models.

Base classes

class QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.

Public static functions

static auto create(const QDomElement& elem, QgsRasterInterface* input) -> QgsRasterRenderer*
Factory method to create a new renderer.

Constructors, destructors, conversion operators

QgsHillshadeRenderer(QgsRasterInterface* input, int band, double lightAzimuth, double lightAltitude)
A renderer for generating live hillshade models.

Public functions

auto altitude() const -> double
Returns the angle of the light source over the raster.
auto azimuth() const -> double
Returns the direction of the light over the raster between 0-360.
auto band() const -> int
Returns the band used by the renderer.
auto block(int bandNo, const QgsRectangle& extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr) -> QgsRasterBlock* override
Read block of data using given extent and size.
auto clone() const -> QgsHillshadeRenderer* override
Clone itself, create deep copy.
auto multiDirectional() const -> bool
Returns true if the renderer is using multi-directional hillshading.
void setAltitude(double altitude)
Set the altitude of the light source.
void setAzimuth(double azimuth)
Set the azimuth of the light source.
void setBand(int bandNo)
Sets the band used by the renderer.
void setMultiDirectional(bool isMultiDirectional)
Sets whether to render using a multi-directional hillshade algorithm.
void setZFactor(double zfactor)
Set the Z scaling factor of the result image.
auto usesBands() const -> QList<int> override
Returns a list of band numbers used by the renderer.
void writeXml(QDomDocument& doc, QDomElement& parentElem) const override
Write base class members to xml.
auto zFactor() const -> double
Returns the Z scaling factor.

Function documentation

static QgsRasterRenderer* QgsHillshadeRenderer::create(const QDomElement& elem, QgsRasterInterface* input)

Factory method to create a new renderer.

Parameters
elem A DOM element to create the renderer from.
input The raster input interface.
Returns A new QgsHillshadeRenderer.

QgsHillshadeRenderer::QgsHillshadeRenderer(QgsRasterInterface* input, int band, double lightAzimuth, double lightAltitude)

A renderer for generating live hillshade models.

Parameters
input The input raster interface
band The band in the raster to use
lightAzimuth The azimuth of the light source
lightAltitude The altitude of the light source

double QgsHillshadeRenderer::altitude() const

Returns the angle of the light source over the raster.

double QgsHillshadeRenderer::azimuth() const

Returns the direction of the light over the raster between 0-360.

QgsRasterBlock* QgsHillshadeRenderer::block(int bandNo, const QgsRectangle& extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr) override

Read block of data using given extent and size.

Parameters
bandNo band number
extent extent of block
width pixel width of block
height pixel height of block
feedback optional raster feedback object for cancelation/preview. Added in QGIS 3.0.

Returns pointer to data. Caller is responsible to free the memory returned.

bool QgsHillshadeRenderer::multiDirectional() const

Returns true if the renderer is using multi-directional hillshading.

void QgsHillshadeRenderer::setAltitude(double altitude)

Set the altitude of the light source.

Parameters
altitude the altitude

void QgsHillshadeRenderer::setAzimuth(double azimuth)

Set the azimuth of the light source.

Parameters
azimuth The azimuth of the light source, between 0 and 360.0

void QgsHillshadeRenderer::setBand(int bandNo)

Sets the band used by the renderer.

void QgsHillshadeRenderer::setMultiDirectional(bool isMultiDirectional)

Sets whether to render using a multi-directional hillshade algorithm.

Parameters
isMultiDirectional set to true to use multi directional rendering

void QgsHillshadeRenderer::setZFactor(double zfactor)

Set the Z scaling factor of the result image.

Parameters
zfactor The z factor

double QgsHillshadeRenderer::zFactor() const

Returns the Z scaling factor.