<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Sadly it doesn't work, here is a search for the post code area LN, but excluding LN1. This should give the polygon of lincoln, with the exception of the town centre district. Instead it creates a polygon for the whole LN post area. <div><br></div><div>Just to clarify, I do want the hole in a polygon.<br><div><br></div><div><div>SELECT ST_AsKML(ST_Union(the_geom)) as the_geom</div><div>FROM postcode_sectors </div><div>WHERE postarea = 'LN' AND NOT com_dist = 'LN1'</div><div><br></div><div><br></div><div><div><?xml version="1.0" encoding="UTF-8"?></div><div><kml xmlns="<a href="http://www.opengis.net/kml/2.2">http://www.opengis.net/kml/2.2</a>"></div><div>  <Placemark></div><div><br></div><div><Polygon><outerBoundaryIs><LinearRing><coordinates>-0.574252637693809,53.2359726746639 -0.570638045173646,53.2342660459289 -0.567956817933028,53.233334871246 -0.542511758566372,53.2276409117944 -0.539261287526225,53.2285001962972 -0.537587144360509,53.23365835124 -0.536621729986015,53.2443903523506 -0.538372820842824,53.2545802514289 -0.53867243559146,53.2902048795337 -0.541250872030082,53.3316560575988 -0.567075865458079,53.3529438083222 -0.549064460589285,53.4257467252708 -0.461252440918993,53.4290079476242 -0.459280037729661,53.4356804144195 -0.491910432874966,53.497600359203 -0.41389940584748,53.5500565803702 -0.310449877650045,53.5267476031091 -0.219352544114183,53.5272954168687 -0.215026390840363,53.5063814691382 -0.203265094143773,53.466744705434 -0.122544300870874,53.4548941206983 0.0264268890418949,53.4620080919002 0.083849617015283,53.496544395631 0.228359151391426,53.408400422663 0.268028563946318,53.342544544341 0.302708719734213,53.2940795243504 0.321850405882593,53.2715163271867 0.234840151689661,53.1942224753385 0.194430850648443,53.213308161178 0.169714736355569,53.2124120839752 0.0834492984598471,53.2348844372266 0.0208307835734331,53.2478135975227 -0.0126938531249155,53.1710150547887 -0.13716904881661,53.1418544045366 -0.150749526290076,53.1243892073786 -0.130710137006856,53.0239835120991 -0.229285061035197,53.0038950480853 -0.338497757654447,53.0609112327498 -0.408675738441825,53.055621865059 -0.452241950934627,53.0579499714055 -0.52047527802287,53.0487392813369 -0.660214167307015,53.0546658032031 -0.714807399468163,53.0584148660486 -0.699290317426583,53.0756434022022 -0.716927624544292,53.1105928908201 -0.674018446595594,53.2187206490539 -0.668182682830745,53.2552110975952 -0.640114978977996,53.2538783112452 -0.574252637693809,53.2359726746639</coordinates></LinearRing></outerBoundaryIs></Polygon></div><div>  </Placemark></div><div></kml></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 60px; text-indent: -60px; font: normal normal normal 12px/normal Helvetica; "><span class="Apple-tab-span" style="white-space:pre">        </span><b>From: </b><span class="Apple-tab-span" style="white-space:pre">   </span><a href="mailto:ssufficool@rov.sbcounty.gov">ssufficool@rov.sbcounty.gov</a></div><p style="margin: 0.0px 0.0px 1.0px 64.0px; text-indent: -64.0px; font: 12.0px Helvetica"><span class="Apple-tab-span" style="white-space:pre">    </span><b>Subject: </b><span class="Apple-tab-span" style="white-space:pre">        </span><b>RE: [postgis-users] Union, but need to exclude any void</b></p><p style="margin: 0.0px 0.0px 1.0px 64.0px; text-indent: -64.0px; font: 12.0px Helvetica"><span class="Apple-tab-span" style="white-space:pre">      </span><b>Date: </b><span class="Apple-tab-span" style="white-space:pre">   </span>1 November 2008 14:58:26 GMT</p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 60px; text-indent: -60px; font: normal normal normal 12px/normal Helvetica; "><span class="Apple-tab-span" style="white-space:pre">       </span><b>To: </b><span class="Apple-tab-span" style="white-space:pre">     </span><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 60px; text-indent: -60px; font: normal normal normal 12px/normal Helvetica; "><span class="Apple-tab-span" style="white-space:pre">   </span><b>Reply-To: </b><span class="Apple-tab-span" style="white-space:pre">       </span><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a></div></div></div><div><br></div><div>I've never had a problem with st_union including holes when it<br>shouldn't. Your query syntax is a bit odd though. Maybe try the<br>following:<br><br>SELECT ST_Union(the_geom) as the_geom<br>FROM territories <br>WHERE is_an_outer_territory = 1<br><br><br><blockquote type="cite"><font class="Apple-style-span" color="#000000">-----Original Message-----<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">From: <a href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a> <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">[<a href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</a>] On <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Behalf Of Toby Rainthorpe<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Sent: Saturday, November 01, 2008 1:37 AM<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">To: PostGIS Users Discussion<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Subject: [postgis-users] Union, but need to exclude any void<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">I have a list of territories, say 9 represented by a tic, tac, toe   <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">board (3 x 3 grid ). A query selects all the outer perimeter (8  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">territories), but omits the central block. If i were then to union  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">this group the resulting polygon would fill, or include this central  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">block, even though I have not exclusively said that that <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">territory has  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">been selected.<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Is there a way of doing a union, or another method on a set of  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">polygons that will result in a polygon being created, but allow for  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">the void not to be included.<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Thanks for your help,<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">Toby<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">SELECT<br></font></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space: pre; "><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">GeomUnion(geom) as the_geom,<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">FROM (<br></font></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space: pre; "><font class="Apple-style-span" color="#000000">   </font></span><font class="Apple-style-span" color="#000000">SELECT (dump(the_geom)).geom FROM territories WHERE  <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">is_an_outer_territory = 1<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">) <br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">_______________________________________________<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">postgis-users mailing list <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions">postgis-users@postgis.refractions</a></div></div></div></div></body></html>