All Products
Search
Document Center

PolarDB:ST_Aspect

Last Updated:Mar 28, 2026

Calculates the compass direction of the steepest downslope for each cell in a raster surface and returns the result as a raster of aspect values.

Syntax

raster ST_Aspect(raster rast, integer pyramid_level, integer band, Box extent, BoxType type, cstring storageOption)

Parameters

ParameterTypeDescription
rastrasterThe raster object.
pyramid_levelintegerThe pyramid level.
bandintegerThe band number.
boxBoxThe area to analyze. Specify the value in '((minX,minY),(maxX,maxY))' format.
typeBoxTypeThe coordinate system for the extent. Valid values: Raster (pixel coordinates) or World (world coordinates).
storageOptioncstringThe storage option for the output raster object. For details, see ST_ClipToRast.

How it works

ST_Aspect computes, for each cell, the direction of the steepest downslope to its neighbors. The result represents the compass bearing of that direction, measured clockwise from north.

  • Output range: 0 to 360 degrees

  • Flat cells: assigned a value of -1 (no downslope direction)

The value in each output cell represents the slope direction of that cell, not the slope magnitude.

Example

The following example calculates the aspect for the area covering pixel coordinates (0,0) to (5,5) at pyramid level 0, band 0, using pixel coordinates:

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