All Products
Search
Document Center

ApsaraDB RDS:ST_Hillshade

Last Updated:Mar 28, 2026

Calculates the hillshade value for each cell of a raster surface and returns an array of hillshades.

Syntax

raster ST_Hillshade(raster rast, integer pyramid_level, integer band, Box extent, BoxType type, float8 zfactor, float8 azimuth, float8 altitude, cstring storageOption);

Parameters

ParameterTypeDescription
rastrasterThe source raster object.
pyramid_levelintegerThe pyramid level of the raster.
bandintegerThe band index (sequence number) to use for the calculation.
extentBoxThe area to analyze. Format: '((minX,minY),(maxX,maxY))'.
typeBoxTypeThe coordinate system used to interpret extent. Valid values: Raster (pixel coordinates) or World (world coordinates).
zfactorfloat8The conversion factor that scales elevation units to match the horizontal coordinate units. Set this when your elevation data and horizontal coordinates use different units — for example, when x,y units are decimal degrees and z units are meters. Default value: 1.
azimuthfloat8The sun's azimuth angle, measured clockwise from north. Valid values: 0360. Default value: 315 (northwest).
altitudefloat8The sun's altitude angle above the horizon. A value of 90 places it directly overhead. Valid values: 090.
storageOptioncstringThe storage option for the output raster. For details, see ST_ClipToRast.

Description

ST_Hillshade models the hypothetical illumination of a raster surface. It assigns a position to an imaginary light source, then computes the illumination value of each cell relative to its neighbors — capturing both the angle of the sun and the local slope and aspect of the terrain.

The output is a raster where each cell contains an integer from 0 to 255. 0 represents the darkest shade (no illumination); 255 represents the brightest shade (maximum illumination). Applying transparency to the hillshade layer enhances the visual quality of terrain analysis and 3D-style map rendering.

When the elevation units differ from the horizontal units (for example, meters vs. decimal degrees), set zfactor to convert them to a common scale.

For a detailed explanation of the hillshade algorithm, see How Hillshade works.

Example

The following example calculates hillshade over a 5×5-pixel extent of a raster at pyramid level 0, band 0, using a z-factor of 4, sun azimuth of 180° (south), and sun altitude of 80°.

SELECT st_hillshade(rast, 0, 0, '(0,0), (5,5)', 'Raster', 4, 180, 80)
FROM t_surface
WHERE id = 1;