ST_GeodesicClosestPoint

ST_GeodesicClosestPoint takes two geometry columns and returns a point column. The output column returns the point on the first geometry that is closest to the second geometry, using geodesic distance calculation. This function returns only one geodesic closest point if there are more than one. If the two input geometries intersect, an empty point geometry is returned. If the two geometry columns are in different spatial references, the function automatically transforms the second geometry into the spatial reference of the first.

This function is more accurate but less performant than ST_ClosestPoint and requires that a spatial reference is set on the input geometry column. To learn more about the difference between planar and geodesic calculations, see Coordinate systems and transformations.

FunctionSyntax
Pythongeodesic_closest_point(geometry1, geometry2)
SQLST_GeodesicClosestPoint(geometry1, geometry2)
ScalageodesicClosestPoint(geometry1, geometry2)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for geodesic_closest_point.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
from geoanalytics_fabric.sql import functions as ST

line_text = 'LINESTRING (-117.61983168124925 34.061452833142205, -117.13262450694835 34.198818997647145, -117.0291395187358 34.01338533049988)'
point_text = 'POINT (-117.34805417060637 34.00267278771285)'
df = spark.createDataFrame([(line_text, point_text)], ["line_wkt", "point_wkt"]) \
          .withColumn("line", ST.line_from_text("line_wkt", 4326)) \
          .withColumn("point", ST.point_from_text("point_wkt", 4326))

df.select(ST.geodesic_closest_point("line", "point").alias("geodesic_closest_point")).show(truncate = False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-----------------------------------------------+
|geodesic_closest_point                         |
+-----------------------------------------------+
|{"x":-117.39749505040815,"y":34.12413977992499}|
+-----------------------------------------------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.