ST_BdMPolyFromText
What is ST_BdMPolyFromText?
ST_BdMPolyFromText builds a MULTIPOLYGON from a MULTILINESTRING WKT whose member linestrings form one or more outer rings and their interior rings. It is the multi-polygon counterpart of ST_BdPolyFromText.
ST_BdMPolyFromText(text WKT, integer srid) → geometrySRID is required. All linestrings must be closed.
When would you use ST_BdMPolyFromText?
Use ST_BdMPolyFromText for legacy ingestion workflows where polygons are stored as collections of independent boundary lines — common in some CAD exchanges and older GIS formats. It automatically classifies lines into outer and inner rings based on nesting.
For single polygons, ST_BdPolyFromText is simpler and safer (it errors on ambiguous inputs).
FAQs
Are open linestrings allowed?
No. Every input linestring must be closed — first vertex equals last.
How does it decide which ring is a hole?
By spatial containment. Rings contained within larger rings are treated as holes of those outer rings.
Does it validate the resulting polygon?
It produces a valid OGC MultiPolygon if the input lines form valid polygonal topology. Run ST_IsValid afterwards to confirm, especially on messy legacy data.
What SRID is assigned?
Whatever is passed as the second argument. SRID is required.