PostGISGeometry Input

ST_GeomFromEWKB

What is ST_GeomFromEWKB?

ST_GeomFromEWKB parses a PostGIS-extended WKB byte string and returns the geometry. EWKB differs from OGC WKB by embedding an SRID and supporting Z/M ordinates.

SQL
ST_GeomFromEWKB(bytea ewkb)geometry

The parsed SRID is applied directly to the output geometry.

When would you use ST_GeomFromEWKB?

Use ST_GeomFromEWKB for round-tripping geometry through binary storage or network transports that preserve the PostGIS EWKB extensions — including SRID tag and higher dimensions. It is the natural reader for the output of ST_AsEWKB and is commonly used in replication, backups, and cross-system transfers within PostGIS-aware toolchains.

Many PostGIS-native drivers emit EWKB by default, so ST_GeomFromEWKB is the appropriate constructor when parsing their outputs back into a geometry column.

FAQs

What makes EWKB different from WKB?

EWKB flags within the type code indicate Z/M dimensions and presence of an SRID, plus a 32-bit SRID field immediately after the type code. Plain OGC WKB has neither.

Is it faster than ST_GeomFromText?

Yes — significantly. Binary parsing avoids the cost of tokenising WKT and parsing floats from text.

Can it parse plain OGC WKB?

Yes — PostGIS parsers are lenient and accept both WKB and EWKB input. SRID will default to 0 if absent.

How is ST_GeomFromEWKB different from ST_GeomFromWKB?

ST_GeomFromWKB is the OGC-named constructor; ST_GeomFromEWKB is the PostGIS-specific name. Both parse either format, but the latter advertises EWKB support more clearly.