This function calculates the slope from each cell of a raster surface and returns an array of slopes in units of degrees.


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


Parameter Description
rast The raster object.
pyramid_level The pyramid level.
Band The sequence number of the band.
box The area to be analyzed, in the format of '((minX,minY),(maxX,maxY))'.
type The coordinate type of the area to be analyzed. You can specify only one value. Valid values:
  • Raster: pixel coordinates
  • World: world coordinates
zfactor The conversion factor that adjusts the units of measure for the vertical (or elevation) units when the units are different from the horizontal coordinate (x,y) units of the input surface. Default value: 1.


The slope function calculates the maximum rate of change in value from each cell to its neighbors. Basically, the maximum change in elevation over the distance between the cell and its eight neighbors identifies the steepest downhill descent from the cell.


select st_slope(rast, 0, 0, '(0,0), (5,5)', 'Raster', 2.0) from t_surface where id=1;
(1 row)