Skip to content

ST_X and ST_Y ​

The ST_X and ST_Y functions return the X (longitude) and Y (latitude) coordinates of a GEOGRAPHY object of subtype ST_Point.

See also:

Syntax ​

sql
ST_X(<input>)

ST_Y(<input>)

Arguments ​

  • <input>: A GEOGRAPHY object of subtype ST_Point.

Returns ​

Returns a FLOAT8 value representing the X or Y coordinate of the input point. Returns NULL if the input is not a GEOGRAPHY object of subtype ST_Point.

Example ​

sql
SELECT ST_X('POINT(1 2)'::GEOGRAPHY);
-- 1.0

SELECT ST_Y('POINT(1 2)'::GEOGRAPHY);
-- 2.0