Description
The ST_ClosestPoints
function returns the closest points between two
geometries.
Syntax
ST_ClosestPoints(WritableGeometry geometry1, WritableGeometry geometry2)
Parameters
Parameter |
Type |
Description |
geometry1
|
WritableGeometry |
The first instance of a WritableGeometry. |
geometry2
|
WritableGeometry |
The second instance of a WritableGeometry. |
Return Values
Return Type |
Description |
Array<WritableGeometry> |
The closest points between the two geometries. The geometries that intersect
are at distance zero from each other, and in this case a shared point is
returned. |
Examples
SELECT ST_ToWKT(result.points[0]) AS point1, ST_ToWKT(result.points[1]) AS point2 FROM table t
LATERAL VIEW OUTER inline(array(named_struct('points', ST_ClosestPoints(ST_GeomFromWKT(t.geometry1, 'epsg:4326'),
ST_GeomFromWkt(t.geometry2, 'epsg:4326'), 'SPHERICAL')))) result;