<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR>
<STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: personal
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
        page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>SELECT geometryn(ogc_geom, generate_series(1, 
numgeometries(ogc_geom)) As poli</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>FROM test_table</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>If you need to use this in a viewer that requires a primary 
key and entry into geometry_columns table or your table is fairly large, then 
you'll need to create a table with something like</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>CREATE TABLE test_table2(gid serial, CONSTRAINT 
pk_test_table2 PRIMARY KEY(gid));</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT 
color=#0000ff>AddGeometryColumn('public', 'test_table2', 'poli', <srid>, 
'POLYGON', 2);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>INSERT INTO test_table2(poli)</FONT></SPAN><SPAN 
class=181590912-27032007>  </DIV>
<DIV dir=ltr align=left>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>SELECT geometryn(ogc_geom, generate_series(1, 
numgeometries(ogc_geom)) As poli</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>FROM test_table;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>CREATE INDEX idx_test_table2_poli  
ON test_table2  USING gist<BR>  (poli);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><FONT face=Arial 
color=#0000ff size=2>Hope that helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=181590912-27032007><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>Leticia<BR><B>Sent:</B> Monday, March 26, 2007 7:17 PM<BR><B>To:</B> 
postgis-devel@postgis.refractions.net<BR><B>Cc:</B> 
postgis-users@postgis.refractions.net<BR><B>Subject:</B> [postgis-users] 
Multipolygons to Polygons<BR><B>Importance:</B> High<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">Can I separate the polygons that conform a 
multipolygon from SQL?<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">For example, If I 
query<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><FONT face="Times New Roman" 
color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: black">SELECT 
AsText(ogc_geom) as poli from test_table <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">I get: <BR>MULTIPOLYGON(((580525.37 
141603.2,580523.3 141629.81,580539.66 141631.09,580540.93 141619.38,580541.46 
141608.63,580541.48 141604.73,580525.37 141603.2),(580527.79 141607.36,580532.68 
141607.38,580532.61 141622.27,580527.73 141622.26,580527.79 141607.36))) 
<BR><BR>which consists of 2 polygons....<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">Can I run a SQL that let me obtain the two 
separate polygons?<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">Thanks in 
advance,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: black">Leticia</SPAN></FONT><FONT face=Arial 
size=2><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p></o:p></SPAN></FONT></P></DIV></BODY></HTML>


<HTML><BODY><P><hr size=1></P><br>
<P><STRONG><br>
The substance of this message, including any attachments, may be<br>
confidential, legally privileged and/or exempt from disclosure<br>
pursuant to Massachusetts law. It is intended solely for the<br>
addressee. If you received this in error, please contact the sender<br>
and delete the material from any computer.<br>
</STRONG></P></BODY></HTML>