ST_GeometryFromText
What is ST_GeometryFromText?
ST_GeometryFromText parses a WKT string and returns a geometry value. It is the OGC Simple Features spelling; ST_GeomFromText is the PostGIS shorthand with identical behaviour.
1ST_GeometryFromText(text WKT) → geometry
2ST_GeometryFromText(text WKT, integer srid) → geometryWithout an SRID argument, the output has SRID 0. The OGC standard does not include EWKT extensions — use ST_GeomFromEWKT for SRID-prefixed strings.
When would you use ST_GeometryFromText?
Use ST_GeometryFromText in code that must remain OGC-compliant and portable across spatial databases — Oracle Spatial, DB2 Spatial, and SQL/MM all implement the same function with the same signature. For PostgreSQL-only code, the shorter ST_GeomFromText is more common.
It is the correct choice in tools whose generated SQL runs against multiple spatial database backends.
FAQs
Is ST_GeometryFromText the same as ST_GeomFromText?
Yes — aliases. ST_GeomFromText is the shorter PostGIS spelling.
Does it accept EWKT?
In PostGIS, practically yes — PostGIS is lenient and parses EWKT through all text constructors. For strict OGC compliance, use pure WKT with an explicit SRID argument.
What SRID is assigned without the second argument?
Zero (0).
When is this alias preferred?
When writing portable spatial SQL that should run on any SQL/MM-conformant database.