PostGISGeometry Input

ST_GeomFromEWKT

What is ST_GeomFromEWKT?

ST_GeomFromEWKT parses a PostGIS-extended WKT string into a geometry value. EWKT adds an SRID prefix and Z/M dimensions not supported by the OGC WKT 1.2 standard.

SQL
ST_GeomFromEWKT(text EWKT)geometry

Example input: 'SRID=4326;POINT Z (-122 37 128)'. The SRID is applied directly without needing a separate ST_SetSRID.

When would you use ST_GeomFromEWKT?

Use ST_GeomFromEWKT when the source text already carries an SRID inline — common in PostGIS-to-PostGIS migrations, logical replication slots, and PostGIS-aware ORMs. It is also the canonical reader for EWKT output produced by ST_AsEWKT, enabling round-trip serialisation.

In debugging sessions, EWKT is human-readable and preserves SRID and dimensionality, making ST_GeomFromEWKT the natural constructor for test fixtures and sample data.

FAQs

What's the difference between EWKT and WKT?

EWKT adds SRID=n; prefix, Z/M ordinate support in type names like POINTZ, and curve/TIN/PolyhedralSurface types beyond OGC SFS 1.1.

Does EWKT omit SRID if none is provided?

Yes. POINT(0 0) without a prefix produces an SRID-0 geometry. Add 'SRID=4326;POINT(0 0)' to tag it.

How is it different from ST_GeomFromText?

ST_GeomFromText parses standard WKT and requires a separate SRID argument. ST_GeomFromEWKT accepts the SRID inline via EWKT prefix.

Can I round-trip geometry through EWKT?

Yes — ST_AsEWKT and ST_GeomFromEWKT are designed to round-trip geometry including SRID and Z/M ordinates exactly.