st_closestpoint function
Applies to: Databricks Runtime 18.0 and above
This feature is in Public Preview.
This feature is not available on Databricks SQL Classic warehouses. To learn more about Databricks SQL warehouses, see SQL warehouse types.
Returns the 2D projection of a point on the first GEOMETRY value that is closest to the second GEOMETRY value with respect to the Euclidean distance.
Syntax
st_closestpoint ( geoExpr1, geoExpr2 )
Arguments
geoExpr1: The firstGEOMETRYvalue.geoExpr2: The secondGEOMETRYvalue.
Returns
Returns the 2D projection of a point on the first GEOMETRY value that is closest to the second GEOMETRY value with respect to the Euclidean distance. The expression returns a ST_DIFFERENT_SRID_VALUES error if the two input geometries have different SRID values. The SRID value of the returned point is the same as the common SRID value of the input geometries. The expression returns the 2D empty point if any of the two input geometries is empty.
NULL is returned if any of the two input geometries is empty.
Error conditions
- If the two input geometries have different SRID values, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
> SELECT st_closestpoint(st_geomfromwkt('MULTIPOINT ZM (-10 10 -1 -10,2 10 -2 -20,20 10 -3 -30)', 3857), st_geomfromwkt('POINT Z (0 0 300)', 3857));
SRID=3857;POINT(2 10)