ST_MLineFromText
What is ST_MLineFromText?
ST_MLineFromText parses a MULTILINESTRING WKT string and returns the geometry. Input WKT that is not a MultiLineString raises an error.
1ST_MLineFromText(text WKT) → geometry
2ST_MLineFromText(text WKT, integer srid) → geometryThe typed constructor enforces the expected multi-line shape.
When would you use ST_MLineFromText?
Use ST_MLineFromText in ingestion pipelines for road networks, rail segments, or river systems stored as MultiLineStrings. The strict type check catches malformed rows at parse time rather than propagating bad data.
For data sources that may mix single and multi LineStrings, use ST_GeomFromText and wrap with ST_Multi.
FAQs
What if the WKT is a plain LineString?
An error. Convert first with ST_Multi(ST_LineFromText(...)) if you need to accept both.
Is SRID required?
No — defaults to 0. Supply explicitly as the second argument for real-world data.
Does it validate non-intersecting lines?
No. MultiLineString members are allowed to cross or share vertices; the constructor only parses structure.
How does it relate to ST_MLineFromWKB?
Same function, different input format — WKT vs WKB. Use WKB for larger binary inputs.