ST_X

Determines the x- coordinate for a GEOMETRY point or the longitude value for a GEOGRAPHY point.

Determines the x- coordinate for a GEOMETRY point or the longitude value for a GEOGRAPHY point.

Behavior type

Immutable

Syntax

ST_X( g )

Arguments

g
Point of type GEOMETRY or GEOGRAPHY

Returns

FLOAT

Supported data types

Data Type GEOMETRY GEOGRAPHY (Perfect Sphere) GEOGRAPHY (WGS84)
Point Yes Yes Yes
Multipoint No No No
Linestring No No No
Multilinestring No No No
Polygon No No No
Multipolygon No No No
GeometryCollection No No No

Examples

The following examples show how to use ST_X.

Returns the x-coordinate:

=> SELECT ST_X(ST_GeomFromText('POINT(3.4 1.25)'));
 ST_X
-----
 3.4
(1 row)

Returns the longitude value:

=> SELECT ST_X(ST_GeographyFromText('POINT(25.34 45.67)'));
 ST_X
-------
 25.34
(1 row)