All Products
Search
Document Center

PolarDB:ST_Slope

Last Updated:Mar 28, 2026

Calculates the slope at each cell of a raster surface and returns the results in radians.

Syntax

raster ST_Slope(raster rast, integer pyramid_level, integer band, Box extent, BoxType type, float8 zfactor, cstring storageOption)

Parameters

ParameterRequiredDescription
rastRequiredThe raster object.
pyramid_levelRequiredThe pyramid level of the raster.
bandRequiredThe band index.
extentRequiredThe area to analyze. Use the format '((minX,minY),(maxX,maxY))'.
typeRequiredThe coordinate system used to define the analysis area. Valid values: Raster (pixel coordinates) and World (world coordinates).
zfactorOptionalA multiplier that converts elevation units to match the horizontal coordinate units. Default value: 1.
storageOptionOptionalThe storage option for the output raster object. For details, see ST_ClipToRast.

How it works

ST_Slope computes the maximum rate of change in a value from each cell to its eight neighboring cells. The steepest downhill descent across those eight neighbors determines the slope value for the cell. Results are expressed in radians.

Example

SELECT st_slope(rast, 0, 0, '(0,0),(5,5)', 'Raster', 2.0)
FROM t_surface
WHERE id = 1;

This query calculates the slope on pyramid level 0, band 0, within the pixel coordinate extent (0,0) to (5,5), using a z-factor of 2.0.