1

How can I convert the line string to multiline string in PostGIS? I have converted geometry points to line string by this: st_makeline(location.shape) but by this command:

  SELECT uuid_generate_v4()                                         AS uuid,
          j."deviceId",
         st_astext(st_linemerge(st_union(j.shape))) AS multiLine
  FROM j
  group by date, j."deviceId" ;

I got this results:

enter image description here

It's result is again line string?

  • Perhaps your GROUP BY returns only one geometry per group. ST_Union and ST_Linemerge do not change a single linestring into MultiLinestring. – user30184 Sep 4 '18 at 12:22
2

Have you tried ST_Multi? https://postgis.net/docs/ST_Multi.html

select st_astext(st_multi(st_geometryfromtext('LINESTRING (30 10, 10 30, 40 40)')))

MULTILINESTRING((30 10,10 30,40 40))

For you this would be

 SELECT uuid_generate_v4()                                         AS uuid,
      j."deviceId",
     st_astext(st_multi(st_linemerge(st_union(j.shape)))) AS multiLine
FROM j
  group by date, j."deviceId" ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.