ST_GeomFromWKB
What is ST_GeomFromWKB?
ST_GeomFromWKB parses OGC well-known binary (WKB) into a geometry. An optional SRID tags the output.
1ST_GeomFromWKB(bytea wkb) → geometry
2ST_GeomFromWKB(bytea wkb, integer srid) → geometryIn PostGIS the parser also accepts EWKB, making ST_GeomFromWKB effectively equivalent to ST_GeomFromEWKB.
When would you use ST_GeomFromWKB?
Use ST_GeomFromWKB for OGC-portable SQL that interacts with spatial databases other than PostGIS — the same function name appears in SQL/MM and most compliant engines. It is faster than WKT parsing and preserves floating-point precision exactly.
It is the canonical input function for clients and drivers that emit OGC WKB, including most non-PostGIS spatial tools.
FAQs
What's the difference from ST_GeomFromEWKB?
ST_GeomFromEWKB is the PostGIS name advertising EWKB support (with SRID and Z/M). ST_GeomFromWKB is the OGC spelling. In PostGIS both parse either format; they differ primarily in documented intent.
What SRID is assigned without the second argument?
Zero, unless the WKB is EWKB with an embedded SRID.
Is it faster than ST_GeomFromText?
Yes. Binary parsing is substantially faster and is preferred for bulk loads and high-throughput pipelines.
How do I generate WKB to pass in?
Use ST_AsBinary(geom) for OGC WKB or ST_AsEWKB(geom) for the PostGIS-extended form.