メインコンテンツまでスキップ

st_closestpoint function

Applies to: check marked yes Databricks Runtime 18.0 and above

Preview

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 first GEOMETRY value.
  • geoExpr2: The second GEOMETRY value.

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

Examples

SQL
> 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)