All Products
Search
Document Center

ApsaraDB RDS:ST_ClosestPoint

Last Updated:Sep 22, 2023

This topic describes the ST_ClosestPoint function. This function compares two geometry objects and returns the 2D point that belongs to one geometry object and is the closest to the other geometry object.

Syntax

geometry  ST_ClosestPoint(geometry  g1, geometry  g2);

Parameters

Parameter

Description

g1

Geometry object 2.

g2

Geometry object 1.

Examples

SELECT ST_AsText(ST_ClosestPoint('LINESTRING(0 -1,0 1)'::geometry,'POINT(1 0)'::geometry));
 st_astext
------------
 POINT(0 0)
(1 row)