Merges the line elements of a MultiLineString by joining them at shared endpoints.
Syntax
geometry ST_LineMerge(geometry amultilinestring)Parameters
| Parameter | Description |
|---|---|
amultilinestring | The geometry object to merge. |
Description
ST_LineMerge joins line elements at their shared endpoints.
The function accepts MultiLineString and LineString objects. For any other geometry type, it returns an empty GeometryCollection.
Warning
ST_LineMerge deletes the M coordinates of MultiLineString objects.
Examples
Basic merge
Two line segments sharing an endpoint are joined 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)该文章对您有帮助吗?