Class: QgsElevationMap¶
- class qgis.core.QgsElevationMap¶
Bases:
sip.wrapper
Stores digital elevation model in a raster image which may get updated as a part of map layer rendering process. Afterwards the elevations can be used for post-processing effects of the rendered color map image.
Elevations are encoded as colors in QImage, thanks to this it is not only possible to set elevation for each pixel, but also to use QPainter for more complex updates of elevations. We encode elevations to 24 bits in range of [-7900, 8877] with precision of three decimal digits, which should give millimiter precision and enough range for elevation values in meters.
New in version 3.28.
QgsElevationMap() Default constructor
QgsElevationMap(size: QSize, devicePixelRatio: float = 1) Constructs an elevation map with the given width and height
QgsElevationMap(image: QImage) Constructs an elevation map from an existing raw elevation
image
. The image must have ARGB32 format and obtained by therawElevationImage()
method.See also
New in version 3.30.
QgsElevationMap(other:
QgsElevationMap
) Copy constructorMethods
Applies eye dome lighting effect to the given
image
.Applies hill shading effect to the given
image
.Combines this elevation map with
otherElevationMap
.Converts a color back to elevation value
Converts elevation value to an actual color
Returns whether the encoded value is a no data value
Returns whether the elevation map is valid.
Returns the no data value for the elevation map
Returns painter to the underlying QImage with elevations
Returns raw elevation image with elevations encoded as color values
- applyEyeDomeLighting(self, image: QImage, distance: int, strength: float, rendererScale: float)¶
Applies eye dome lighting effect to the given
image
. The effect makes angled surfaces darker and adds silhouettes in case of larger differences of elevations between neighboring pixels.The
distance
parameter tells how many pixels away from the original pixel to sample neighboring pixels. Normally distance of 2 pixels gives good results.The
strength
parameter adjusts how strong the added shading will be. Good default for this value seems to be 1000.The
rendererScale
parameter adjusts scale of elevation values. It is recommended to set this to the map’s scale denominator to get similarly looking results at different map scales.- Parameters:
image (QImage) –
distance (int) –
strength (float) –
rendererScale (float) –
- applyHillshading(self, image: QImage, multiDirectional: bool, altitude: float, azimuth: float, zFactor: float, cellSizeX: float, cellSizeY: float)¶
Applies hill shading effect to the given
image
.If the
multidirectinal
parameter isTrue
, the algorithm will considered a multi horizontal directional light to apply the shading.The parameter
altitude
(could also be named zenith) is the vertical direction of the light.The parameter
azimuth
is the horizontal direction of the light considered ifmultidirectional
isFalse
.The parameter
zFactor
is the vertical exageration of the terrain.The parameters
cellSizeX
andcellSizeY
are the sizes of the elevation map cells in unit consistent with the unit of the encoded elevation in this elevation map.New in version 3.30.
- Parameters:
image (QImage) –
multiDirectional (bool) –
altitude (float) –
azimuth (float) –
zFactor (float) –
cellSizeX (float) –
cellSizeY (float) –
- combine(self, otherElevationMap: QgsElevationMap, method: Qgis.ElevationMapCombineMethod)¶
Combines this elevation map with
otherElevationMap
. This elevation map keeps its size and takes elevation values of otherElevationMap that is not null for same row and column following the combinemethod
. The other elevation map can have a different size, only rows and columns contained in this elevation map will be considered.New in version 3.30.
- Parameters:
otherElevationMap (QgsElevationMap) –
method (Qgis.ElevationMapCombineMethod) –
- decodeElevation(colorRaw: int) float ¶
Converts a color back to elevation value
- Parameters:
colorRaw (int) –
- Return type:
float
- encodeElevation(z: float) int ¶
Converts elevation value to an actual color
- Parameters:
z (float) –
- Return type:
int
- isNoData(self, colorRaw: int) bool ¶
Returns whether the encoded value is a no data value
- Parameters:
colorRaw (int) –
- Return type:
bool
- isValid(self) bool ¶
Returns whether the elevation map is valid.
New in version 3.30.
- Return type:
bool
- noDataValue(self) float ¶
Returns the no data value for the elevation map
- Return type:
float
- painter(self) QPainter ¶
Returns painter to the underlying QImage with elevations
- Return type:
QPainter
- rawElevationImage(self) QImage ¶
Returns raw elevation image with elevations encoded as color values
- Return type:
QImage