ST_Azimuth takes two geometry columns and returns a double column representing the normalized azimuth in degrees. The output azimuth angle is heading from the first geometry to the second geometry. The angle is referenced from the north and is positive clockwise. This function requires that the first geometry column have a spatial reference set.
If the two geometry columns are in different spatial references, the function will automatically transform the second geometry into the spatial reference of the first.
Function | Syntax |
---|---|
Python | azimuth(geometry1, geometry2) |
SQL | ST |
Scala | azimuth(geometry1, geometry2) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for azimuth.
Examples
from geoanalytics_fabric.sql import functions as ST, Point
from pyspark.sql import functions as F
data = [
(Point(-176, -15),),
(Point(-178, -15),),
(Point(-176, -17),)
]
df = spark.createDataFrame(data, ["point"])
df.select(F.round(ST.azimuth(ST.point(-178.0, -17.0, 4326), ST.srid("point", 4326)), 9).alias("azimuth")).show()
+------------+
| azimuth|
+------------+
|44.148521949|
| 0.0|
|90.292398857|
+------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |