<!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><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2>Dylan,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2>So are you saying that with ST_Union you got topological 
intersection errors but with ST_MemUnion you didn't?  This would be very 
intriguing if that were the case</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2>since in theory both should yield the same result albeit 
slightly differently.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2>ST_Union does an array collect and then unions where 
as ST_MemUnion keeps on unioning 2 geometries at a time.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><FONT face=Arial 
color=#0000ff size=2>Thanks,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=020223112-06052008><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>Dylan 
Lorimer<BR><B>Sent:</B> Monday, May 05, 2008 9:47 PM<BR><B>To:</B> 
postgis-users@postgis.refractions.net<BR><B>Subject:</B> [postgis-users] Re: 
ST_Difference Perplexes Me!<BR></FONT><BR></DIV>
<DIV></DIV>Wanted to follow-up on this with the SQL that worked in the end. 
Firstly...thanks so much Regina! I've no confidence that I ever would have 
figured out this sql on my own, and yet looking at it now it makes perfect 
sense!<BR><BR>So here it is in case anyone else is interested:<BR><BR>- 
vmap_countries contains country boundaries<BR>- published_both_prototype_union 
contains dissolved polygons all over the world (millions of them.)<BR><BR>CREATE 
TABLE not_meter_or_less_prototype AS <BR>SELECT 
ST_Difference(vmap_countries.the_geom, C.the_sum_geom), 
vmap_countries.country_na<BR>FROM vmap_countries INNER JOIN (SELECT 
ST_MemUnion(published_both_prototype_union.the_geom) As 
the_sum_geom,<BR>vmap_countries.country_na<BR>   FROM vmap_countries 
INNER JOIN published_both_prototype_union ON 
ST_Intersects(vmap_countries.the_geom, 
published_both_prototype_union.the_geom)<BR>               
WHERE vmap_countries.country_na IN ('China', 'India', 
'Japan')<BR>               
GROUP BY vmap_countries.country_na ) As C<BR>ON  vmap_countries.country_na 
= C.country_na;<BR><BR>Many many (many) thanks to those on the list that have 
helped me out!<BR>Cheers,<BR>dylan<BR></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>

<P><hr size=1></P>
<P><STRONG><font size="2" color="339900"> Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. </p> <p> </font></STRONG></P>