重要
此功能目前以公共预览版提供。
返回从第一个点到第二个点的以北为基准的方位角,以弧度表示 [0, 2π)。
有关相应的 Databricks SQL 函数,请参阅 st_azimuth 函数。
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.st_azimuth(col1=<col1>, col2=<col2>)
参数
| 参数 | 类型 | Description |
|---|---|---|
col1 |
pyspark.sql.Column 或 str |
表示点的第一个 Geography 或 Geometry 值。 |
col2 |
pyspark.sql.Column 或 str |
表示点的第二个 Geography 或 Geometry 值。 |
注释
输入要么是两个 GEOGRAPHY 值,要么是两个 GEOMETRY 值,否则返回错误。
这两个输入值应表示点,否则返回错误。
这两个点应具有相同的 SRID 值,否则将返回错误。
如果两个点的 2D 投影相等,则返回的 azimuth 为零。
None 如果两个输入值中的任何一个为空,则返回 。
例子
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)]