Returns the Well-Known Text (WKT) representation of a geometry or geography object, prefixed with the spatial reference identifier (SRID).
Syntax
text ST_AsEWKT(geometry g1);
text ST_AsEWKT(geography g1);Parameters
| Parameter | Description |
|---|---|
g1 | The geometry or geography object to convert. |
Usage notes
The output format is
SRID=<srid>;<wkt>— for example,SRID=4326;POLYGON((0 0,0 1,1 1,0 0)).WKT does not guarantee full floating-point precision. To preserve exact coordinate values, use ST_AsBinary or ST_AsEWKB instead.
To get WKT without the SRID prefix, use ST_AsText.
Supported geometry types:
3D objects
Circular strings and curves
Polyhedral surfaces
Triangles and triangulated irregular network (TIN) surfaces
Examples
Return a WKT string with an SRID
SELECT ST_AsEWKT(ST_GeomFromText('POLYGON((1 1,1 2,2 2,2 1,1 1))',4326));
st_asewkt
------------------------------------------
SRID=4326;POLYGON((1 1,1 2,2 2,2 1,1 1))
(1 row)Return a WKT string without an SRID
SELECT ST_AsEWKT(ST_GeomFromText('POLYGON((1 1,1 2,2 2,2 1,1 1))'));
st_asewkt
--------------------------------
POLYGON((1 1,1 2,2 2,2 1,1 1))
(1 row)See also
ST_AsText — returns WKT without the SRID prefix
ST_AsBinary — returns WKB without the SRID prefix
ST_AsEWKB — returns EWKB with the SRID prefix