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
| Parameter | Required | Description |
|---|---|---|
rast | Required | The raster object. |
pyramid_level | Required | The pyramid level of the raster. |
band | Required | The band index. |
extent | Required | The area to analyze. Use the format '((minX,minY),(maxX,maxY))'. |
type | Required | The coordinate system used to define the analysis area. Valid values: Raster (pixel coordinates) and World (world coordinates). |
zfactor | Optional | A multiplier that converts elevation units to match the horizontal coordinate units. Default value: 1. |
storageOption | Optional | The 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.