Pular para o conteúdo principal

st_azimuth function

Applies to: check marked yes Databricks Runtime 18.0 and above

Preview

This feature is in Public Preview.

nota

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 first GEOGRAPHY or GEOMETRY value.
  • geoExpr2: The second GEOGRAPHY or GEOMETRY value.

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

Examples

SQL
-- 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