ST_BdPolyFromText
What is ST_BdPolyFromText?
ST_BdPolyFromText builds a single POLYGON from a MULTILINESTRING WKT whose member linestrings form exactly one outer ring and zero or more inner rings. The function raises an error if the lines form more than one polygon.
ST_BdPolyFromText(text WKT, integer srid) → geometrySRID is required. The input linestrings must be closed and form valid polygonal boundaries.
When would you use ST_BdPolyFromText?
Use ST_BdPolyFromText when ingesting legacy GIS data stored as lists of boundary lines — common in older CAD exchange formats and some topological schemas that maintain rings as independent line features. It assembles the rings back into a polygon in one step.
For datasets where the boundary may contain multiple polygons, use ST_BdMPolyFromText instead.
FAQs
What if the WKT contains two outer rings?
An error is raised. Use ST_BdMPolyFromText for inputs that may form multiple polygons.
Do the linestrings need to be closed?
Yes. Each ring must have matching first and last vertices.
Is SRID required?
Yes. Unlike ST_GeomFromText, SRID is mandatory on this OGC constructor.
How is this different from ST_MakePolygon?
ST_MakePolygon takes a single LineString for the exterior plus optional hole LineStrings. ST_BdPolyFromText takes a MultiLineString WKT as a single text argument and infers which rings are exterior and interior.