ST_LineMerge — Returns a LineString as a result of merging a MultiLineString.
geometry ST_LineMerge(
bytea
Geometry)
;
Returns a LineString as a result of merging a MultiLineString. If the geometry can't be merged, original MultiLineString is returned.
This function supports GeometryCollections. If the incoming geometry is a Polygon, it will return its exterior ring. |
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
--Connected MultiLineString SELECT ST_AsEWKT( ST_LineMerge(ST_GeomFromEWKT('MULTILINESTRING ((0 0, 10 10, 20 10, 30 30),(30 30, 40 40, 50 40))'))); --Result LINESTRING (0 0, 10 10, 20 10, 30 30, 40 40, 50 40) --Unconnected MultiLineString SELECT ST_AsEWKT( ST_LineMerge(ST_GeomFromEWKT('MULTILINESTRING ((0 0, 10 10, 20 10),(30 30, 40 40, 50 40))')) ); --Result MULTILINESTRING ((0 0, 10 10, 20 10), (30 30, 40 40, 50 40)) --GeometryCollection SELECT ST_AsEWKT( ST_LineMerge(ST_GeomFromEWKT(' GEOMETRYCOLLECTION(MULTILINESTRING ((0 0,20 10,30 30),(30 30, 40 40)), POINT(0 0) )'))); --Result LINESTRING (0 0, 20 10, 30 30, 40 40) SELECT ST_AsText(ST_LineMerge(ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'))); --Result LINESTRING (0 0, 10 0, 10 10, 0 10, 0 0)