1

I have the following polygons:

01060000000300000001, 01060000000400000001, 01060000000400000001, 01060000000200000001, 01060000000100000001, 01060000000200000001, 01060000000100000001, 01060000000300000001, 01060000000100000001, 01060000000100000001, 01060000000100000001, 01060000000100000001

And I'd like to merge them using:

SELECT st_union(ARRAY(SELECT geom FROM areas))

And I get: https://pastebin.com/V18JtCz8 (I should paste here but it's above the char count - if you're reading this and the link doesn't work, it's simply the output of the above)

When I plot this output, there are holes (deliberate) but I'd like to just take the outline of the polygon as the new polygon.

How would I go about this?

Kazuhito
  • 30,746
  • 5
  • 69
  • 149
Bill
  • 167
  • 11
  • 1
    External links are unlikely to be followed (and likely to fail over time). Instead, include a screenshot of a map. – Vince Jun 16 '17 at 10:48

1 Answers1

3

To do this, simply call ST_ExteriorRing on the geom to create the outline and then create a polygon from that.

So SELECT ST_MakePolygon(ST_ExteriorRing(st_union(ARRAY(SELECT geom FROM areas))))

This will fill in all the gaps.

Read more here: https://postgis.net/docs/ST_ExteriorRing.html and here: https://postgis.net/docs/ST_MakePolygon.html

Bill
  • 167
  • 11