Calculates the aspect of each cell on the surface of a raster object and returns the result as a raster.
Syntax
raster ST_Aspect(raster rast, integer pyramid_level, integer band, Box extent, BoxType type, cstring storageOption);Use cases
Ski run planning: Identify north-facing slopes on a mountain to find terrain suitable for ski runs.
Solar radiation modeling: Determine sun exposure at each location based on slope direction.
Hydrology analysis: Find south-facing slopes where snow melts first to predict runoff risk.
Parameters
| Parameter | Type | Description |
|---|---|---|
rast | raster | The raster object. |
pyramid_level | integer | The pyramid level. |
band | integer | The band index. |
extent | Box | The bounding box of the area to analyze. Use the format '((minX,minY),(maxX,maxY))'. |
type | BoxType | The coordinate system used to define the analysis area. Valid values: Raster (pixel coordinates) and World (world coordinates). Use Raster when your extent is in pixel or cell space. Use World when your extent is in geographic or projected coordinates. |
storageOption | cstring | The storage option for the output raster object. For details, see ST_ClipToRast. |
Description
ST_Aspect identifies the downslope direction of the maximum rate of change in value from each cell to its neighboring cells — the compass direction that a slope faces.
Output values represent compass directions measured clockwise from north, in degrees (0–360).
Flat cells with no downslope direction are assigned an aspect of -1 in the output raster.
Example
SELECT st_aspect(rast, 0, 0, '(0,0), (5,5)', 'Raster') FROM t_surface WHERE id = 1;