All Products
Search
Document Center

PolarDB:ST_Aspect

Last Updated:Mar 28, 2026

Computes the aspect (downslope direction) of each cell on a raster surface and returns the result as a raster object.

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 sequence number.
extentBoxThe area to analyze, in '((minX,minY),(maxX,maxY))' format.
typeBoxTypeThe coordinate type used to define the analysis area. Valid values: Raster (pixel coordinates) and World (world coordinates).
storageOptioncstringThe storage option for the raster object. For details, see ST_ClipToRast.

How it works

ST_Aspect identifies the downslope direction of the maximum rate of change from each cell to its neighboring cells. This direction is the slope direction.

Each output cell contains the compass bearing of the aspect, measured clockwise from north in degrees.

Usage notes

  • Aspect values are in degrees, ranging from 0 to 360, measured clockwise from north.

  • Cells with zero slope (flat areas) are assigned an aspect of -1.

  • Set type to Raster to use pixel coordinates, or World to use world coordinates.

Example

The following example computes the aspect of a 5x5 pixel area (from pixel (0,0) to pixel (5,5)) on band 0 at pyramid level 0, using pixel coordinates.

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