ST_X()
All functions > GEOSPATIAL > ST_X()
Returns the X coordinate of a point (or longitude for geography).
Signatures
X coordinate
Returns: X coordinate (or longitude)
ST_X(point: T) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
point | T | Yes | A Point geometry or geography |
With:
T: Custom types: GEOM_POINT | GEOG_POINT
Signature notes:
- Input must be a Point; other sub kinds return NULL
- On GEOGRAPHY, returns the longitude in degrees (first argument to ST_GEOGPOINT)
- GEOG_POINT uses X = longitude, Y = latitude; mixing lat/long when calling constructors breaks ST_X / ST_Y results
- Returns NULL if the input is NULL
Examples
FeatureQL
SELECT
f1 := ST_X(ST_GEOMPOINT(3.0, 4.0)), -- X of a geometry point
f2 := ST_X(ST_GEOGPOINT(-122.4194, 37.7749)) -- Longitude of a geography point
;Result
| f1 VARCHAR | f2 VARCHAR |
|---|---|
| 3.0 | -122.4194 |
On this page