PostGISGeometry Input

ST_PolygonFromText

What is ST_PolygonFromText?

ST_PolygonFromText parses a POLYGON WKT string and returns the geometry. Non-Polygon inputs raise an error.

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

When would you use ST_PolygonFromText?

Use ST_PolygonFromText in pipelines where the ingested records are strictly single polygons — administrative boundaries stored as single regions, individual land parcels, or simple catchment areas. The type check catches MultiPolygon rows that slipped in by mistake.

For polymorphic inputs, use the general ST_GeomFromText.

FAQs

What if the WKT is a MultiPolygon?

An error. Use ST_MPolyFromText for that case.

Does it validate topology?

No. Well-formedness of the WKT is checked; run ST_IsValid to confirm OGC validity.

Can I include interior rings (holes)?

Yes — WKT format POLYGON((outer), (hole1), (hole2), ...) is supported.

Is SRID required?

No — defaults to 0.