<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco">Thanks for your answer Regina,</font></font><div><font class="Apple-style-span" face="Monaco"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco">but ST_Difference does not solve the problem : </font></font><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco">ST_Difference and ST_Symdifference give the same polygon but the export by pgsql2shp failled.</font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><br class="webkit-block-placeholder"></font></font></div><div><font class="Apple-style-span" color="#0000FF" face="Arial" size="2"><span class="Apple-style-span" style="font-size: 10px;"><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# create table temp as </span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion-# select  r.gid, <font class="Apple-style-span" color="#FF0219">ST_Difference</font>(r.the_geom,i.the_geom) as the_geom from recouv as r, recouv as i where i.gid=2 and r.gid=1;</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">SELECT</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# ALTER TABLE temp ADD PRIMARY KEY (gID);</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "temp_pkey" for table "temp"</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">ALTER TABLE</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# SELECT geometrytype(the_geom), Nrings(the_geom), area2d(the_geom) from temp;</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> geometrytype | nrings |      area2d      </span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">--------------+--------+------------------</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> POLYGON      |      2 | 2177713.02017212</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">(1 row)</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br class="webkit-block-placeholder"></span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br class="webkit-block-placeholder"></span></font></font></font></div><div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# create table temp as </span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion-# select  r.gid, <font class="Apple-style-span" color="#FF0219">ST_symDifference</font>(r.the_geom,i.the_geom) as the_geom from recouv as r, recouv as i where i.gid=2 and r.gid=1;</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">SELECT</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# ALTER TABLE temp ADD PRIMARY KEY (gID);</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "temp_pkey" for table "temp"</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">ALTER TABLE</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">conversion=# SELECT geometrytype(the_geom), Nrings(the_geom), area2d(the_geom) from temp;</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> geometrytype | nrings |      area2d      </span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">--------------+--------+------------------</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"> POLYGON      |      2 | 2177713.02017212</span></font></font></font></div><div><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" face="Monaco"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;">(1 row)</span></font></font></font></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" color="#000000" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;">The two polygons are goods and well displayed in QGIS but exported shapefiles are empty or corrupted.</span></font></div><div><font class="Apple-style-span" color="#000000" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br class="webkit-block-placeholder"></span></font></div></div></span></font><div><font class="Apple-style-span" color="#0000FF" face="Arial" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" color="#0000FF" face="Arial" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font><div><div>Le 12 mars 08 à 12:51, Obe, Regina a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2">I'm guessing your result may be a Geometrycollection which ESRI shape has no clue what to do with.</font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2">If I understand you correctly, I think you really should be using ST_Difference instead of ST_SymDifference.</font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2">So ST_Difference(polygon2, polygon1) - will give you that portion of polygon2 which does not intersect with polygon1 which would give you a polygon with polygon1 removed (a doughnut so to speak).</font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2">The ST_Symdifference will give you that portion of polygon2 not in polygon1 + polygon1 not in polygon2 = the holed polygon you want + an empty geometry collection -> a geometry collection if taken strictly. </font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2"> I'm not sure if PostGIS will throw out the second part (the empty collection) - and at anyrate is a waste of processing power to even compute it.</font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2"></font></span> </div> <div dir="ltr" align="left"><span class="829444111-12032008"><font face="Arial" color="#0000ff" size="2">Hope that helps,</font></span></div> <div dir="ltr" align="left"><span class="829444111-12032008"><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 [<a href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</a>] <b>On Behalf Of </b>Ghislain Geniaux<br><b>Sent:</b> Wednesday, March 12, 2008 6:29 AM<br><b>To:</b> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><b>Subject:</b> [postgis-users] problem creating and exporting a polygon with holeusing pgsql2shp<br></font><br></div> <div></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">Using a postgis table with Two polygons, in which polygon 1 entirely contained in polygon 2, I've create a new polygon with a hole using : </font></div> <div style="MIN-HEIGHT: 16px; MARGIN: 0px; FONT: 13px Verdana"><br></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">------ </font></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">create table matable2 as </font></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">select  r.gid, area(symdifference(r.the_geom,i.the_geom)) as area,(symdifference(r.the_geom,i.the_geom)) as the_geom from matable as r, matable as i where i.gid=2 and r.gid=1; </font></div> <div style="MIN-HEIGHT: 16px; MARGIN: 0px; FONT: 13px Verdana"><br></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">ALTER TABLE matable2 ADD PRIMARY KEY (GID); </font></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">\q </font></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">pgsql2shp -f ext.shp conversion 'select * from matable2' </font></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">----- </font></div> <div style="MIN-HEIGHT: 16px; MARGIN: 0px; FONT: 13px Verdana"><br></div> <div style="MARGIN: 0px"><font style="FONT: 13px Verdana" face="Verdana" size="4">Area is correct, display of the polygon in QGIS is also correct, but the export by pgsl2shp produce an empty shapefile. </font></div> <div style="MIN-HEIGHT: 16px; MARGIN: 0px; FONT: 13px Verdana"><br></div> <div style="MARGIN: 0px"><span class="Apple-style-span" style="FONT-SIZE: 13px; FONT-FAMILY: Verdana">How to deal with this problem?</span></div> <div style="MARGIN: 0px"><font class="Apple-style-span" face="Verdana" size="3"><span class="Apple-style-span" style="FONT-SIZE: 13px"><br class="webkit-block-placeholder"></span></font></div> <div style="MARGIN: 0px">------------------------------------------</div> <div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto; orphans: 2; widows: 2"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto; orphans: 2; widows: 2"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; -khtml-text-decorations-in-effect: none; -apple-text-size-adjust: auto; orphans: 2; widows: 2"> <div style="MARGIN: 0px">Geniaux Ghislain</div> <div style="MARGIN: 0px"><br></div></span></span></span></div><br><div><br class="khtml-block-placeholder"></div><hr size="1"><div><br class="khtml-block-placeholder"></div><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><div><br class="khtml-block-placeholder"></div><hr size="1"><div><br class="khtml-block-placeholder"></div><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. </font></strong></p><strong><font size="2" color="339900"> </font></strong><p><strong><font size="2" color="339900"> </font></strong></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">postgis-users mailing list</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a></div> </blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">------------------------------------------</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Geniaux Ghislain</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">INRA SAD Ecodéveloppement</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Site Agroparc</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Domaine St Paul</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">84914 Avignon Cedex 9</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Tél : 04 32 72 25 64</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Fax : 04 32 72 25 62</div><br class="Apple-interchange-newline"></span></span></span> </div><br></div></div></div></body></html>