<!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=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>Not quite clear what you are trying to 
do</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>1) Do you have table a with n rows and table b with m rows 
(each having the same fields) and you want table c with (m + n) 
rows.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>This is a regular old SQL union and not a spatial union 
</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>So would be done with</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>INSERT INTO c(field1,field2, .., 
the_geom)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>SELECT a.field1, a.field2, ... 
a.the_geom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>FROM a</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>UNION ALL</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>SELECT b.field1, b.field2, ... 
b.the_geom</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><FONT face=Arial 
color=#0000ff size=2>FROM b;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>or are you trying to do a 
spatial union or intersection and in what case what records are you trying to 
group together into a geometry or join by</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>There are so many 
permutations of spatial unions and spatial intersections - that its hard to give 
an answer without having more details about what you are trying to 
accomplish.</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>e.g a spatial 
intersection result may looks something like this</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>2) </SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008><SPAN 
class=792315312-26032008><FONT face=Arial color=#0000ff size=2>INSERT INTO 
c(field1,field2, field3,.., the_geom)</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>SELECT a.field1, 
a.field2, b.field1 as field3 .. ST_Intersection(a.the_geom, b.the_geom) as 
the_geom</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>FROM a INNER JOIN b on 
(a.zip = b.zip (or whatever field) and ST_Intersects(a.the_geom, 
b.the_geom)</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=792315312-26032008>Hope that 
helps,</SPAN></DIV>
<DIV dir=ltr align=left><SPAN 
class=792315312-26032008>Regina</SPAN></DIV></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>K. 
Pandey<BR><B>Sent:</B> Tuesday, March 25, 2008 11:51 PM<BR><B>To:</B> 
postgis-users@postgis.refractions.net<BR><B>Subject:</B> [postgis-users] Spatial 
Analysis/Union of shapefiles<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>I want to perform union of two shape files using postgresql.</DIV>
<DIV>I converted the shape files to postgres tables using shp2pgsql 
utility.</DIV>
<DIV>How to perform the union/intersection of these two tables.</DIV>
<DIV>Once the union/intersection is completed, I can convert the union file back 
to shapefile using pgsql2shp utility.</DIV>
<DIV> </DIV>
<DIV>-- <BR>Kamal Pandey<BR>Dehradun </DIV></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>