<div dir="ltr">Hello,<div><br></div><div>You may be willing to use ST_MakePolygon - it accepts holes and puts them into right place.</div><div><br></div><div><a href="https://postgis.net/docs/ST_MakePolygon.html">https://postgis.net/docs/ST_MakePolygon.html</a> <br></div><div><br></div><div>ST_Polygonize isn't a logical reverse of ST_Boundary. You can pass reconstructed polygons via ST_SymDifference to cut them out.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">пн, 4 июн. 2018 г. в 9:44, Marcin Mionskowski <<a href="mailto:mionskowskimarcin@gmail.com">mionskowskimarcin@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I don't know if it is a bug.<br>
Polygonizing a multilinestring (boundary of polygon with holes) results in GeometryCollection of:<br>
1. Big polygon with holes (original);<br>
2. Polygons of holes.<br>
<br>
Probably it's becouse ST_Polygonize can't "know" if a multilinestring represents a polygon with holes or a set of polygons.<br>
<br>
If you compare original polygon with ST_GeometryN(geom,1) result of ST_Polygonize it will return TRUE.<br>
<br>
Try:<br>
SELECT ST_Equals(a.geom,p.geom)<br>
 FROM areas a<br>
        JOIN (SELECT id,ST_GeometryN(ST_Polygonize(ST_Boundary(geom)),1) geom FROM areas GROUP BY id) p USING(id)<br>
<br>
<br>
Regards,<br>
Marcin<br>
<br>
On Sun, 03 Jun 2018 23:36:40 +0200, Paulo Pires <<a href="mailto:paulopires16@gmail.com" target="_blank">paulopires16@gmail.com</a>> wrote:<br>
<br>
> Hello,<br>
><br>
><br>
> Please, see this 2 polygons example.<br>
><br>
> I Convert them to linestrings (ST_Boundary) and then to polygons again<br>
> (ST_Polygonize) and I can't reach to same polygons...<br>
><br>
> This is a bug from ST_Polygonize function?<br>
><br>
> DROP TABLE IF EXISTS areas;<br>
> CREATE TABLE areas (<br>
> id integer,<br>
> geom GEOMETRY<br>
> );<br>
><br>
> INSERT INTO areas (id, geom) VALUES<br>
> (1, ST_GeometryFromText('POLYGON (( 152475.78309656942<br>
> 348633.83643648896 100.0 , 152819.11124438787 348634.30014856393 100.0<br>
> , 152813.0950157867 348346.43594807677 100.0 , 151948.4678701025<br>
> 348359.31090193643 100.0 , 151945.74402745243 348463.90645969921 100.0<br>
> , 152474.91289439827 348458.49244305107 100.0 , 152475.78309656942<br>
> 348633.83643648896 100.0 ), ( 152527.33647845959 348558.83199005033<br>
> 100.0 , 152529.2307245445 348407.29230325681 100.0 ,<br>
> 152709.18410261182 348403.50381108694 100.0 , 152709.18410261182<br>
> 348558.83199005033 100.0 , 152527.33647845959 348558.83199005033 100.0<br>
> ), ( 152006.95163549151 348435.14978348627 100.0 , 152006.95163549151<br>
> 348385.89938685647 100.0 , 152092.19270658147 348384.00514083228 100.0<br>
> , 152091.24558356937 348434.20266047411 100.0 , 152006.95163549151<br>
> 348435.14978348627 100.0 ))')),<br>
> (2, ST_GeometryFromText('POLYGON (( 152527.33647845959<br>
> 348558.83199005033 100.0 , 152709.18410261182 348558.83199005033 100.0<br>
> , 152709.18410261182 348403.50381108694 100.0 , 152529.22480595027<br>
> 348407.76579079556 100.0 , 152527.33647845959 348558.83199005033 100.0<br>
> ))'))<br>
> ;<br>
><br>
> DROP TABLE IF EXISTS poly2line;<br>
> create table poly2line as<br>
> SELECT ST_Boundary((ST_Dump(geom)).geom) AS geom<br>
> FROM areas;<br>
><br>
> DROP TABLE IF EXISTS polygonize;<br>
> CREATE TABLE polygonize AS<br>
> select (st_dump(ST_Polygonize(geom))).geom as geom<br>
> from poly2line;<br>
><br>
><br>
><br>
> Paulo Pires<br>
><br>
> ------------------------------<br>
> phone  964592113<br>
> e-mail  <a href="mailto:paulopires16@gmail.com" target="_blank">paulopires16@gmail.com</a><br>
> crypt   myPGP public key for encryption emails<br>
> <<a href="http://kerckhoffs.surfnet.nl/pks/lookup?op=get&search=0x878711213981EEF6" rel="noreferrer" target="_blank">http://kerckhoffs.surfnet.nl/pks/lookup?op=get&search=0x878711213981EEF6</a>><br>
> links    facebook <<a href="http://facebook.com/paulopires16" rel="noreferrer" target="_blank">http://facebook.com/paulopires16</a>> · twitter<br>
> <<a href="http://twitter.com/#!/paulopires16" rel="noreferrer" target="_blank">http://twitter.com/#!/paulopires16</a>> · linkedin<br>
> <<a href="http://www.linkedin.com/pub/paulo-pires/36/4a7/607" rel="noreferrer" target="_blank">http://www.linkedin.com/pub/paulo-pires/36/4a7/607</a>> · netlog<br>
> <<a href="http://netlog.com/paulopires16" rel="noreferrer" target="_blank">http://netlog.com/paulopires16</a>> · javase<br>
> <<a href="http://download.oracle.com/javase/6/docs/api/" rel="noreferrer" target="_blank">http://download.oracle.com/javase/6/docs/api/</a>> · oracle<br>
> <<a href="http://www.oracle.com/us/syndication/feeds/index.html" rel="noreferrer" target="_blank">http://www.oracle.com/us/syndication/feeds/index.html</a>><br>
> ------------------------------<br>
><br>
> Aviso Legal:<br>
> Esta mensagem de Paulo Pires é destinada exclusivamente ao destinatário.<br>
> Pode conter informação confidencial ou legalmente protegida. A incorrecta<br>
> transmissão desta mensagem não significa a perda de confidencialidade. Se<br>
> esta mensagem for recebida por engano, por favor envie-a de volta para o<br>
> remetente e apague-a do seu sistema de imediato. É proibido a qualquer<br>
> pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte<br>
> desta mensagem.<br>
><br>
> Disclaimer:<br>
> This message from Paulo Pires is destined exclusively to the intended<br>
> receiver. It may contain confidential or legally protected information. The<br>
> incorrect transmission of this message does not mean the loss of its<br>
> confidentiality. If this message is received by mistake, please send it<br>
> back to the sender and delete it from your system immediately. It is<br>
> forbidden to any person who is not the intended receiver to use, distribute<br>
> or copy any part of this message.<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>