ST_AZIMUTH()
All functions > GEOSPATIAL > ST_AZIMUTH()
Returns the azimuth angle in radians from point A to point B, measured clockwise from north (positive Y axis).
Signatures
Azimuth
Returns: Azimuth in radians in the range [0, 2π)
ST_AZIMUTH(geo1: T, geo2: T) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
geo1 | T | Yes | Origin point |
geo2 | T | Yes | Target point |
With:
T: Custom types: GEOM_POINT
Signature notes:
- Returns angle in radians (not degrees), measured clockwise from the positive Y axis (north)
- Range is [0, 2π); due north = 0, due east = π/2 (~1.5708), due south = π, due west = 3π/2—users expecting compass degrees (e.g. 90° east) should multiply by
180.0 / PI() - Returns NULL if either point is NULL or if both points are equal
- GEOMETRY only: planar azimuth in SRID coordinate units. GEOGRAPHY has no spherical form here; convert with ST_TOGEOMETRY
Availability
| Status | Backends |
|---|---|
| Not available | clickhouse, bigquery, mysql |
Examples
Geometry (planar)
FeatureQL
RETURN
-- Due north: azimuth is 0
f1 := ST_AZIMUTH(ST_GEOMPOINT(0.0, 0.0), ST_GEOMPOINT(0.0, 1.0)),
-- Due east: π/2 radians (not 90° unless converted)
f2 := ST_AZIMUTH(ST_GEOMPOINT(0.0, 0.0), ST_GEOMPOINT(1.0, 0.0))
;Result
| f1 DECIMAL | f2 DECIMAL |
|---|---|
| 0.0 | 1.5707963 |