<!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.16481" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial
color=#0000ff size=2>Ravi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial
color=#0000ff size=2><SPAN class=947490613-17092007>Is the graphic one
record or multiple records? If multiple records - I'm afraid you may
be asking 2 conflicting questions depending on your dataset so I'm not sure
there is anything that can remedy that aside from treating them as two separate
questions.</SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
size=2><FONT color=#0000ff>I'm <SPAN class=947490613-17092007>also
</SPAN>afraid you are getting into territory I'm<SPAN class=947490613-17092007>
very </SPAN><SPAN class=947490613-17092007>weak</SPAN>. You may want to
investigate use of st_boundary<SPAN class=947490613-17092007> (which will give
you a multilinestring of a polygon/multipolygon boundary and
then apply buildarea to that).</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN class=947490613-17092007>The below should get
rid of some redundant overlapping polygons, but probably won't completely
satisfy what you want to do. I'm also thinking you may want to be
using intersection instead of geomunion for the inner part. But again
depends what you are trying to answer.</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><SPAN
class=947490613-17092007>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><FONT face=Arial
color=#0000ff size=2>INSERT INTO abc(code, info,
the_geom)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT color=#0000ff><FONT
face=Arial size=2>SELECT newtb.code, </FONT><A href="http://newtb.info/"
target=_blank><SPAN id=lw_1190034122_1
style="BACKGROUND: none transparent scroll repeat 0% 0%"><FONT face=Arial
color=#003399 size=2>newtb.info</FONT></SPAN></A><FONT face=Arial
size=2>, <SPAN class=947490613-17092007>multi(</SPAN><SPAN
class=947490613-17092007>buffer(</SPAN>geomunion(<SPAN
class=947490613-17092007>distinct </SPAN>newtb.cgeom)<SPAN
class=947490613-17092007>, 0.0))</SPAN> as
thenewgeom</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>FROM </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2>( SELECT <SPAN
class=691344412-13092007>a</SPAN>.code, <SPAN class=691344412-13092007><A
href="http://b.info/" target=_blank><SPAN
id=lw_1190034122_2>b</SPAN>.info</SPAN></FONT></FONT></FONT></A><FONT face=Arial
color=#0000ff size=2>, <SPAN
class=947490613-17092007><STRONG>intersection</STRONG></SPAN>(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>) as cgeom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT color=#0000ff><FONT
face=Arial><FONT size=2> FROM <SPAN
class=691344412-13092007>a</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> INNER
JOIN <SPAN class=691344412-13092007>b</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial><FONT
size=2> <FONT color=#0000ff>UNION
ALL</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
size=2> <FONT color=#0000ff>SELECT <SPAN
class=691344412-13092007>a</SPAN>.code, null As info, <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
as cgeom</FONT> </FONT>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> FROM <SPAN
class=691344412-13092007>a</SPAN> </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> LEFT
JOIN <SPAN class=691344412-13092007>b</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> WHERE <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
IS NULL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial><FONT
size=2> <FONT color=#0000ff>UNION
ALL</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial><FONT
size=2> <FONT color=#0000ff>SELECT null as code, <SPAN
class=691344412-13092007><A href="http://b.info/" target=_blank><FONT
color=#003399><SPAN
id=lw_1190034122_3>b</SPAN>.info</FONT></SPAN></A>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
as cgeom</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff
size=2>
FROM <SPAN class=691344412-13092007>b</SPAN> LEFT JOIN <SPAN
class=691344412-13092007>a</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff
size=2>
WHERE <SPAN class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> IS NULL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>) AS newtb</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT color=#0000ff><FONT
face=Arial size=2>GROUP BY newtb.code, </FONT><A href="http://newtb.info/"
target=_blank><SPAN id=lw_1190034122_4><FONT face=Arial color=#003399
size=2>newtb.info</FONT></SPAN></A></FONT></SPAN></DIV></SPAN></DIV></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007> </SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007></SPAN></FONT></FONT></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN class=947490613-17092007>Hope that
helps,</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=913305812-17092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=947490613-17092007>Regina</SPAN></FONT></FONT></FONT></SPAN></DIV></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>RAVI
KUMAR<BR><B>Sent:</B> Monday, September 17, 2007 9:04 AM<BR><B>To:</B>
postgis<BR><B>Subject:</B> [postgis-users] UNION<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Hi Regina,</DIV>
<DIV>giving the link to show actual how the UNION of polygons is not working as
per expectation.</DIV>
<DIV>Please see the clips in the link.</DIV>
<DIV> </DIV>
<DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><SPAN
class=691344412-13092007><FONT face=Arial color=#0000ff size=2>CREATE TABLE
abc(code smallint, info smallint) with oids;</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><SPAN
class=691344412-13092007><FONT face=Arial color=#0000ff size=2>SELECT
AddGeometryColumn('public', 'abc', 'the_geom', 4326, 'MULTIPOLYGON',
2);</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><FONT face=Arial
color=#0000ff size=2>--The insert</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007><FONT face=Arial
color=#0000ff size=2>INSERT INTO abc(code, info,
the_geom)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=691344412-13092007>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>SELECT newtb.code, <A href="http://newtb.info/"
target=_blank><SPAN id=lw_1190034122_1
style="BACKGROUND: none transparent scroll repeat 0% 0%"><FONT
color=#003399>newtb.info</FONT></SPAN></A>, geomunion(newtb.cgeom) as
thenewgeom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>FROM </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>( SELECT <SPAN
class=691344412-13092007>a</SPAN>.code, <SPAN class=691344412-13092007><A
href="http://b.info/" target=_blank><FONT color=#003399><SPAN
id=lw_1190034122_2>b</SPAN>.info</FONT></SPAN></A>, geomunion(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>) as cgeom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial><FONT
color=#0000ff><FONT size=2> FROM <SPAN
class=691344412-13092007>a</SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> INNER
JOIN <SPAN class=691344412-13092007>b</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007> <FONT
face=Arial color=#0000ff size=2>UNION ALL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007> <FONT
face=Arial color=#0000ff size=2>SELECT <SPAN
class=691344412-13092007>a</SPAN>.code, null As info, <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
as cgeom</FONT>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> FROM <SPAN
class=691344412-13092007>a</SPAN> </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> LEFT
JOIN <SPAN class=691344412-13092007>b</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2> WHERE <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
IS NULL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007> <FONT
face=Arial color=#0000ff size=2>UNION ALL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007> <FONT
face=Arial color=#0000ff size=2>SELECT null as code, <SPAN
class=691344412-13092007><A href="http://b.info/" target=_blank><FONT
color=#003399><SPAN
id=lw_1190034122_3>b</SPAN>.info</FONT></SPAN></A>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
as cgeom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff
size=2>
FROM <SPAN class=691344412-13092007>b</SPAN> LEFT JOIN <SPAN
class=691344412-13092007>a</SPAN> ON <SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN class=691344412-13092007>etry</SPAN>
&& <SPAN class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> AND intersects(<SPAN
class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>, <SPAN
class=691344412-13092007>b</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff
size=2>
WHERE <SPAN class=691344412-13092007>a</SPAN>.geom<SPAN
class=691344412-13092007>etry</SPAN> IS NULL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>) AS newtb</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=217440812-13092007><FONT face=Arial
color=#0000ff size=2>GROUP BY newtb.code, <A href="http://newtb.info/"
target=_blank><SPAN id=lw_1190034122_4><FONT
color=#003399>newtb.info</FONT></SPAN></A></FONT></SPAN></DIV></SPAN></DIV></DIV>
<DIV> </DIV>
<DIV>May be I should be using different syntax for such a result.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><A
href="http://www.kodakgallery.com/I.jsp?c=cjns10h3.8ovw4dsn&x=0&y=w3kbw0"
target=_blank rel=nofollow><SPAN id=lw_1190033901_2
style="BACKGROUND: #dceeff"><FONT face=Verdana color=#003399
size=1>http://www.kodakgallery.com/I.jsp?c=cjns10h3.8ovw4dsn&x=0&y=w3kbw0</FONT></SPAN></A><FONT
face=Verdana size=1> </FONT></DIV>
<DIV><FONT face=Verdana size=1></FONT> </DIV>
<DIV><FONT face=Verdana size=1>Ravi Kumar</FONT></DIV>
<P>
<HR SIZE=1>
Catch up on <A
href="http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658 ">fall's
hot new shows</A> on Yahoo! TV. Watch previews, get listings, and more!
</BODY></HTML>
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
</STRONG></P></BODY></HTML>