Merges the line elements of a MultiLineString into one or more LineString objects by joining them at shared endpoints.
Syntax
geometry ST_LineMerge(geometry amultilinestring);Parameters
| Parameter | Description |
|---|---|
amultilinestring | The geometry object to merge. |
Description
ST_LineMerge accepts MultiLineString and LineString objects.
Note
Passing any geometry type other than MultiLineString or LineString returns an empty GeometryCollection.
Warning
ST_LineMerge drops the m coordinates of the input geometry.
Examples
Merging two connected line segments
The two input segments share the endpoint (2 1), so ST_LineMerge joins them into a single LineString.
SELECT ST_AsText(ST_LineMerge(ST_GeomFromText('MULTILINESTRING((1 1,2 1),(2 1,2 2))')));Output:
st_astext
-------------------------
LINESTRING(1 1,2 1,2 2)
(1 row)该文章对您有帮助吗?