2

I am working with a set of data that includes common IDs and overlapping linestrings/geoms. I would like to combine the overlapping lines based on their common IDs, preferably in postgres. I can run the combo process on either format. The linestrings are lat/long.

The data as linestring (lat/long) looks like this (with each # being a lat/long pair):

ID     geometry-points
11     1 3 56
11     12 45 7
11      234 6 8
12       3 5
12     1 
12           78

And would return like this

11     12345678
12     13578
1
  • 1
    Great question. Would love to hear an answer!
    – Krizzle
    Dec 5, 2019 at 19:56

1 Answer 1

2

You want to union and dissolve those lines based on ID; this is trivial with ST_Union working on groups:

SELECT id,
       ST_Union(geom) AS geom
FROM   <your_table>
GROUP BY
        id
;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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