Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In postgis I'm using the following query to buffer lines to polygons:

UPDATE rivers
  SET poly = ST_Multi(ST_Buffer(lines, 0.01))
  where id = 1;

The column 'lines' is a MultiLine and the column 'poly' is a MultiPoly. In record #1 'lines' contains 92 overlapping Line types. I would expect the result of St_Buffer to be a MultiPoly, but it is just a Polygon (If I run the above query without St_Multi I get a sql error. What am I doing wrong?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You have to use ST_DUMP first to split the multilines into seperate lines, buffer those and then collect them into a multi again:

UPDATE rivers
  SET poly = p.npoly
  FROM  (
    SELECT ST_MULTI(ST_COLLECT(ST_BUFFER((q.dump).geom,1) ORDER BY (q.dump).path)) as npoly    
    FROM (
     SELECT ST_DUMP(lines) AS dump from rivers   where id = 1
          ) as q
          ) as p
   where id = 1
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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