<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD>
<BODY
style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space">
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>Toby,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>I agree with Stanley that it is probably not a ST_Union
problem. I'm guessing there is something wrong with your WHERE
clause. Keep in mind PostgreSQL is case sensitive so if by
chance</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>you had something like ln1 instead of LN1 in the
com_dist field, then the ln1s would be picked up as NOT ....</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>To rule out ST_Union as the culprit, can you do a simple
attribute query</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>SELECT postarea, com_dist, gid</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>FROM postcode_sectors</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>WHERE <FONT face="Times New Roman" color=#000000
size=3>postarea = 'LN' AND NOT com_dist = 'LN1'</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>ORDER BY postarea, com_dist</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>Also I tend to do com_dist <> 'LN1' , but that
shouldn't matter.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>Hope that helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546501819-01112008><FONT face=Arial
color=#0000ff size=2>Regina</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Toby
Rainthorpe<BR><B>Sent:</B> Saturday, November 01, 2008 2:19 PM<BR><B>To:</B>
PostGIS Users Discussion<BR><B>Subject:</B> Re: [postgis-users] Union, but need
to exclude any void<BR></FONT><BR></DIV>
<DIV></DIV>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: 0px 0px 0px 60px; FONT: 12px Helvetica; TEXT-INDENT: -60px"><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: 0px 0px 1px 64px; FONT: 12px Helvetica; TEXT-INDENT: -64px"><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: 0px 0px 1px 64px; FONT: 12px Helvetica; TEXT-INDENT: -64px"><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: 0px 0px 0px 60px; FONT: 12px Helvetica; TEXT-INDENT: -60px"><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: 0px 0px 0px 60px; FONT: 12px Helvetica; TEXT-INDENT: -60px"><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>