This topic describes the ST_AsEWKT function. This function returns the Well-Known Text (WKT) string that represents a geometry object or a geography object. The WKT string that is returned contains spatial reference identifier (SRID) metadata.
Syntax
text ST_AsEWKT(geometry g1);
text ST_AsEWKT(geography g1);
Parameters
Parameter | Description |
---|---|
g1 | The geometry object or geography object whose WKT representation you want to obtain. |
Description
- If you want to obtain a standard WKT string that does not contain an SRID, use the ST_AsText function.
- The WKT format cannot ensure precision. If you want to prevent floating-point numbers of a specific decision from being truncated, we recommend that you use the ST_AsBinary function or the ST_AsEWKB function.
- This function supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Examples
- Obtain a WKT string that contains 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)
- Obtain a WKT string that does not contain 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)