Reputation: 5932
This is my part of multilinestring :
MULTILINESTRING((59.6338836103678 36.3408616511151,59.6336405351758 36.3410074124113),(59.648377513513 36.3329201331362,59.6481338515878 36.3326094998047,59.6478482801467 36.3322287937626))
When i execute this command in postgresql :
SELECT ST_AsText(ST_LineMerge(ST_GeomFromText('MULTILINESTRING((59.6338836103678 36.3408616511151,59.6336405351758 36.3410074124113),(59.648377513513 36.3329201331362,59.6481338515878 36.3326094998047,59.6478482801467 36.3322287937626))')));
I do not get linestring?I got still MULTILINESTRING
?
Upvotes: 2
Views: 2386
Reputation: 980
I assume that you want to merge multilinestring to one linestring if possible if not then merge to N linestrings where N is the lowest possible number of linestrings.
I add another multilinestring that can be marged to one linestring to check if it works as intented.
with edges as (select ST_GeomFromText('MULTILINESTRING((59.6338836103678 36.3408616511151,59.6336405351758 36.3410074124113),
(59.648377513513 36.3329201331362,59.6481338515878 36.3326094998047,59.6478482801467 36.3322287937626))') geom
UNION
select ST_GeomFromText('MULTILINESTRING((0 0,1 1),
(1 1,30 20,100 120)
)') geom)
select row_number() over () id,geom, st_astext(geom)
FROM (select distinct (st_dump(st_linemerge(geom))).geom geom
from (select st_union(geom) geom
from edges e) a
) b;
Upvotes: 2
Reputation: 3118
It's returning the original multilinestring, which st_linemerge does when it can't merge. It looks like your multilinestring has separate pieces which is why it cannot be merged. I get the following when I put it into QGIS.
There is some more information on this issue here: https://gis.stackexchange.com/questions/83069/cannot-st-linemerge-a-multilinestring-because-its-not-properly-ordered
Upvotes: 3