You don't need to do array unless you have a reason for that LIMIT. ST_Union is an overloaded function: One version is an aggregate and one takes an array of geometries.
So below is a bit shorter to write: SELECT ST_Union(poly) FROM portal.catalog WHERE cat.type = 'CADRG'; -----Original Message----- From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-boun...@postgis.refractions.net] On Behalf Of DrYSG Sent: Wednesday, August 15, 2012 2:39 PM To: postgis-users@postgis.refractions.net Subject: [postgis-users] Merge rectangles In the table portal.catalog column poly is a geometry (always a rectangle, with datum EPSG 4326) column type is a text field. I want to find all the records who have a type of "CADRG" and merge the polygons into the simplest shape that covers all the items in the array (I.e. if they form a square with a hole, then I want that, if it has to be a multipolygon, so be it). Is this the correct way to do that? SELECT ST_AsText(ST_Union( ARRAY( SELECT poly FROM portal.catalog as cat WHERE cat.type='CADRG' LIMIT 10 ) ) ) -- View this message in context: http://postgis.17.n6.nabble.com/Merge-rectangles-tp4999357.html Sent from the PostGIS - User mailing list archive at Nabble.com. _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users