ST_ToMultiLine function
The ST_ToMultiLine function takes a geometry as an input parameter and converts it to a multilinestring. The resulting multilinestring is represented in the spatial reference system of the specified geometry.
The specified geometry must be empty, a multilinestring, or a linestring. If the specified geometry is null, then null is returned.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes that represents
the geometry that is converted to a multilinestring.
A geometry can be converted to a multilinestring if it is empty, a linestring, or a multilinestring. If the conversion cannot be performed, then an exception condition is raised (SQLSTATE 38SUD).
Return type
ST_MultiLineString
Example
In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display
This example
illustrates the use of the ST_ToMultiLine function.
CREATE TABLE sample_geometries (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geometries
VALUES (1, ST_Geometry ('multilinestring ((0 10, 0 0, 10 0),
(23 43, 27 34, 35 12))', 1) ),
(2, ST_Geometry ('linestring z (0 10 1, 0 0 3, 10 0 5)', 1) ),
(3, ST_Geometry ('point empty', 1) ),
(4, ST_Geometry ('multipolygon empty', 1) )
In the following SELECT statement, the ST_ToMultiLine
function is used to return multilinestrings converted to ST_MultiLineString
from the static type of ST_Geometry.
SELECT CAST( ST_AsText( ST_ToMultiLine(geometry) )
AS VARCHAR(130) ) LINES
FROM sample_geometries
Results:
LINES
--------------------------------------------------------------
MULTILINESTRING (( 0.000000 10.000000, 0.000000 0.000000,
10.000000 0.000000),(23.000000 43.000000,
27.000000 34.000000, 35.000000 12.000000))
MULTILINESTRING Z((0.000000 10.000000 1, 0.000000 0.000000 3,
10.000000 0.000000 5))
MULTILINESTRING EMPTY
MULTILINESTRING EMPTY
