I am running a Spark application, using Apache Sedona.
I am trying to compute the bearing/azimuth between two coordinates, using following script:
import org.apache.sedona.sql.utils.SedonaSQLRegistrator
SedonaSQLRegistrator.registerAll(spark)
spark.sql("SELECT DEGREES(ST_AZIMUTH(ST_POINT(9.942731, 57.042649), ST_POINT(9.940315, 57.04348))) AS azimuth").show
Resulting in 288 degrees:
scala> spark.sql("SELECT DEGREES(ST_AZIMUTH(ST_POINT(9.942731, 57.042649), ST_POINT(9.940315, 57.04348))) AS azimuth").show
+-----------------+
| azimuth|
+-----------------+
|288.9810116333513|
+-----------------+
Problem is, when I try to verify the bearing using several online tools, like e.g. https://www.sunearthtools.com/tools/distance.php, they all compute the angle to 302 degrees. As all the web tools agree, I guess Sedona computes the angle wrong.
So, I expected the result to be 302 degrees, but got 288.
Can anyone see if I made an error, how to fix it, or if there are a problem with Sedona's computation?
Versions: Scala: 2.11 Spark: 2.4 Sedona: 1.2.1-incubating jts-core: 1.19.0 geotools-wrapper: 1.1.0-25.2