Class: QgsRelief

Produces colored relief rasters from DEM.

List of all members, including inherited members

Constructor

__init__

Enums

Result

Calculation results.

Methods

addReliefColorClass

Adds a relief color.

calculateOptimizedReliefClasses

Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression.

clearReliefColors

Clears all existing relief colors.

exportFrequencyDistributionToCsv

Writes frequency of elevation values to a file for manual inspection

processRaster

Starts the calculation.

reliefColors

Returns a list of all relief colors.

setReliefColors

Sets the list of relief colors.

setZFactor

Sets the z factor, which controls vertical elevation exaggeration.

zFactor

Returns the z factor, which controls vertical elevation exaggeration.

class qgis.analysis.QgsRelief[source]

Bases: object

__init__(inputFile: str | None, outputFile: str | None, outputFormat: str | None)

Constructor for QgsRelief.

Parameters:
ReliefColor

alias of QgsRasterReliefColor

class Result(*values)

Bases: IntEnum

Calculation results.

Added in version 4.2.

  • Success: Calculation succeeded

  • InvalidInput: Invalid input layer

  • OutputCreationFailed: Creation of output layer failed

  • InvalidInputSize: Input raster was too small (at least 3 rows are required)

  • Canceled: Operation was canceled

Canceled = 7
InvalidInput = 1
InvalidInputSize = 6
OutputCreationFailed = 3
Success = 0
addReliefColorClass(self, color: QgsRasterReliefColor)[source]

Adds a relief color.

See also

reliefColors()

Parameters:

color (QgsRasterReliefColor)

calculateOptimizedReliefClasses(self) list[QgsRasterReliefColor]

Calculates class breaks according with the method of Buenzli (2011) using an iterative algorithm for segmented regression.

Return type:

list[QgsRasterReliefColor]

Returns:

True in case of success

clearReliefColors(self)[source]

Clears all existing relief colors.

See also

reliefColors()

exportFrequencyDistributionToCsv(self, file: str | None) bool[source]

Writes frequency of elevation values to a file for manual inspection

Parameters:

file (Optional[str])

Return type:

bool

processRaster(self, feedback: QgsFeedback | None = None) QgsRelief.Result[source]

Starts the calculation.

Reads from the intput input file and stores the result in the output file.

Parameters:

feedback (Optional[QgsFeedback] = None) – feedback object that receives update and that is checked for cancellation.

Return type:

QgsRelief.Result

Returns:

result code. Prior to QGIS 4.2 the results were returned as a raw integer value.

reliefColors(self) list[QgsRasterReliefColor]

Returns a list of all relief colors.

Return type:

list[QgsRasterReliefColor]

setReliefColors(self, c: Iterable[QgsRasterReliefColor])[source]

Sets the list of relief colors.

See also

reliefColors()

Parameters:

c (Iterable[QgsRasterReliefColor])

setZFactor(self, factor: float)[source]

Sets the z factor, which controls vertical elevation exaggeration.

See also

zFactor()

Parameters:

factor (float)

zFactor(self) float[source]

Returns the z factor, which controls vertical elevation exaggeration.

See also

setZFactor()

Return type:

float