Name

ST_Azimuth — Returns the angle in radians from the horizontal of the vector defined by pointA and pointB

Synopsis

float ST_Azimuth(geometry pointA, geometry pointB);

Description

Returns the azimuth of the segment defined by the given Point geometries, or NULL if the two points are coincident. Return value is in radians.

The Azimuth is mathematical concept defined as the angle, in this case measured in radian, between a reference plane and a point

Availability: 1.1.0

Azimuth is especially useful in conjunction with ST_Translate for shifting an object along its perpendicular axis. See upgis_lineshift Plpgsqlfunctions PostGIS wiki section for example of this.

Examples

--Azimuth in degrees

SELECT ST_Azimuth(ST_MakePoint(1,2), ST_MakePoint(3,4))/(2*pi())*360 as degAz,
	ST_Azimuth(ST_MakePoint(3,4), ST_MakePoint(1,2))/(2*pi())*360 As degAzrev

degaz	degazrev
------	---------
45		225

See Also

ST_MakePoint, ST_Translate