st_azimuth function
Applies to: Databricks Runtime 18.0 and above
This feature is in Public Preview.
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns the north-based azimuth from the first point to the second in radians in [0, 2π).
Syntax
st_azimuth ( geoExpr1, geoExpr2 )
Arguments
geoExpr1: The firstGEOGRAPHYorGEOMETRYvalue.geoExpr2: The secondGEOGRAPHYorGEOMETRYvalue.
Returns
Returns a DOUBLE value equal to the north-based azimuth from the first point to the second.
The result is in radians in the range [0, 2π).
The inputs are expected to be either two GEOGRAPHY or two GEOMETRY values, otherwise a DATATYPE_MISMATCH error is returned.
Both input values are expected to represent points, otherwise a ST_INVALID_ARGUMENT.INVALID_TYPE error is returned.
If the 2D projections of the two points are equal, the returned azimuth is zero.
NULL is returned if any of the two input GEOGRAPHY or GEOMETRY values is empty.
If at least one of the input points is empty, NULL is returned.
Error conditions
- If any of the two input geometries is not a point, the function returns ST_INVALID_ARGUMENT.INVALID_TYPE.
- If the two input geometries have different SRID values, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
-- The inputs are `GEOMETRY` values. The output (Cartesian azimuth) is displayed in degrees.
> SELECT round(st_azimuth(st_geomfromtext('POINT(0 45)'), st_geomfromtext('POINT(1 46)')) * 180.0 / pi(), 3);
45.0
-- The inputs are `GEOGRAPHY` values. The output (geographic azimuth on the WGS84 ellipsoid) is displayed in degrees.
> SELECT round(st_azimuth(st_geogfromtext('POINT(0 45)'), st_geogfromtext('POINT(1 46)')) * 180.0 / pi(), 3);
34.76