PostGISGeometry Input

ST_PointFromText

What is ST_PointFromText?

ST_PointFromText parses a POINT WKT string and returns the geometry. Non-Point WKT raises an error.

SQL
1ST_PointFromText(text WKT)geometry
2ST_PointFromText(text WKT, integer srid)geometry

When would you use ST_PointFromText?

Use ST_PointFromText to parse point coordinates from text inputs — geocoding API responses, user-supplied coordinates, CSV rows. The strict type check ensures malformed rows fail at parse rather than silently pass through.

For building points from numeric X/Y columns, ST_MakePoint or ST_SetSRID(ST_MakePoint(...), srid) is usually cheaper since it avoids text parsing.

FAQs

Is it faster than ST_MakePoint for numeric inputs?

No — ST_MakePoint is faster because it skips text parsing. Use ST_PointFromText only when the source is actually WKT.

What SRID is used without the second argument?

Zero. Always supply the SRID for coordinates intended for spatial joins.

Does it accept Z and M ordinates?

Yes. POINT Z (x y z) and POINT ZM (x y z m) are parsed as XYZ and XYZM respectively.

What format does WKT for a Point use?

POINT(x y) with coordinates space-separated and parenthesised. Whitespace after POINT is optional.