All Products
Search
Document Center

PolarDB:ST_Slope

Last Updated:Mar 28, 2026

Calculates the slope of each cell across the surface of a raster object and returns the slopes as an array in radians.

Syntax

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

Parameters

ParameterDescription
rastThe raster object.
pyramid_levelThe pyramid level.
bandThe band number.
extentThe area to analyze, specified as '((minX,minY),(maxX,maxY))'.
typeThe coordinate type used to define the analysis area. Valid values: Raster (pixel coordinates), World (world coordinates).
zfactorThe z-factor used to convert elevation units when they differ from the horizontal coordinates of the input surface. Default value: 1.
storageOptionThe storage option of the raster object. For more information, see ST_ClipToRast.

How it works

ST_Slope calculates the maximum rate of change in elevation from each cell to its eight neighboring cells. This maximum change across neighboring cells identifies the steepest downhill descent from the cell.

Example

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

This example analyzes pyramid level 0, band 0, over the extent (0,0)–(5,5) in pixel coordinates, with a z-factor of 2.0, against the row where id = 1 in the t_surface table.