这是我的multilinestring部分:
MULTILINESTRING((59.6338836103678 36.3408616511151,59.6336405351758 36.3410074124113),(59.648377513513 36.3329201331362,59.6481338515878 36.3326094998047,59.6478482801467 36.3322287937626))
当我在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))')));
我没有得到线串?我还是MULTILINESTRING
吗?
答案 0 :(得分:3)
它返回原始的多行字符串,当st_linemerge无法合并时,它将执行此操作。看起来您的multilinestring有单独的片段,这就是为什么它不能合并的原因。将其放入QGIS后,我会得到以下信息。
此处有关于此问题的更多信息:https://gis.stackexchange.com/questions/83069/cannot-st-linemerge-a-multilinestring-because-its-not-properly-ordered
答案 1 :(得分:0)
我假设您希望将多线串合并为一个线串(如果可能的话),然后合并为N个线串,其中N是线串的最小数目。
我添加了另一个多行字符串,可以将其与一个行字符串绑定,以检查其是否按预期工作。
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;