ST_X

Determine the x coordinate of a point geometry, or set the x coordinate of a point geometry to a particular value.

Syntax

ST_X(pgeo); 
ST_X(pgeo, x);
pgeo
The input point geometry.

Type: ST_GEOMETRY(ANY)

x
The value to which the x coordinate of the input point geometry is to be set.

Type: DOUBLE

Returns

The value that is returned depends on whether an x value is specified:
  • If an x value is not specified, a value of type DOUBLE that indicates the x coordinate of the input point geometry.
  • If an x value is specified, a value of type ST_GEOMETRY(126) that contains the input point geometry with the newly set x coordinate.

Examples

SELECT inza..ST_X(inza..ST_Point(0.0, 1.0));

ST_X
------
0
(1 row)
SELECT inza..ST_AsText(inza..ST_X(inza..ST_Point(0.0, 1.0), 5));

ST_ASTEXT
-----------
POINT (5 1)
(1 row)
SELECT inza..ST_AsText(inza..ST_X(inza..ST_Point(0.0, 1.0, 2.0), 5));

ST_ASTEXT
-----------
POINT Z (5 1 2)
(1 row)
SELECT inza..ST_AsText(inza..ST_X(inza..ST_Point(0.0, 1.0, 2.0, 3.0), 5));
 
ST_ASTEXT
-----------
POINT ZM (5 1 2 3)
(1 row)