PostGISGeometry Input

ST_GeogFromText

What is ST_GeogFromText?

ST_GeogFromText parses a WKT or EWKT string and returns a geography value. Without an explicit SRID, geography defaults to WGS84 (EPSG:4326).

SQL
ST_GeogFromText(text EWKT) → geography

The function accepts both plain POINT(-122 37) WKT and EWKT with a prefix like SRID=4326;POINT(-122 37).

When would you use ST_GeogFromText?

Use ST_GeogFromText when inserting literal coordinates into a geography column — a common case for apps that want metre-accurate distance calculations out of the box. Geography always interprets operations on the ellipsoid, so distance in metres and area in square metres come for free.

It is also useful in migration scripts that translate text-based inputs from APIs or CSVs into PostGIS-compatible geography values without an intermediate geometry cast.

FAQs

Do I need to supply an SRID?

No — if omitted, WGS84 (4326) is assumed. You can explicitly override with EWKT prefix SRID=xxxx;.

Can I use any SRID with geography?

Only geographic CRSs registered as geography-compatible in spatial_ref_sys. In practice, 4326 is universally supported; other geographic CRSs may work but are rarely used.

How is it different from ST_GeographyFromText?

They are aliases — identical function.

Does it validate the resulting geography?

No. Validity is left to the caller; use ST_IsValid on a geometry cast if validity matters.