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
| Parameter | Description |
|---|---|
rast | The raster object. |
pyramid_level | The pyramid level. |
band | The band number. |
extent | The area to analyze, specified as '((minX,minY),(maxX,maxY))'. |
type | The coordinate type used to define the analysis area. Valid values: Raster (pixel coordinates), World (world coordinates). |
zfactor | The z-factor used to convert elevation units when they differ from the horizontal coordinates of the input surface. Default value: 1. |
storageOption | The 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.