Share via


st_azimuth

Important

This feature is in Public Preview. You can confirm preview enrollment on the Previews page. See Manage Azure Databricks previews.

Returns the north-based azimuth from the first point to the second in radians in [0, 2π).

For the corresponding Databricks SQL function, see st_azimuth function.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.st_azimuth(col1=<col1>, col2=<col2>)

Parameters

Parameter Type Description
col1 pyspark.sql.Column or str The first Geography or Geometry value representing a point.
col2 pyspark.sql.Column or str The second Geography or Geometry value representing a point.

Notes

The inputs are expected to be either two GEOGRAPHY or two GEOMETRY values, otherwise an error is returned. Both input values are expected to represent points, otherwise an error is returned. The two points are expected to have the same SRID value, otherwise an error is returned.

If the 2D projections of the two points are equal, the returned azimuth is zero.

None is returned if any of the two input values is empty.

Examples

from pyspark.databricks.sql import functions as dbf
from pyspark.sql.functions import round, lit
import math

df = spark.createDataFrame([('POINT(0 45)', 'POINT(1 46)')], ['wkt1', 'wkt2'])
df.select(round(dbf.st_azimuth(dbf.st_geomfromtext('wkt1'), dbf.st_geomfromtext('wkt2')) * 180.0 / math.pi, 3).alias('result')).collect()
[Row(result=45.0)]