[postgis-users] ST_Polygonize bug?

Marcin Mionskowski mionskowskimarcin at gmail.com
Sun Jun 3 23:42:43 PDT 2018


Hi,
I don't know if it is a bug.
Polygonizing a multilinestring (boundary of polygon with holes) results in GeometryCollection of:
1. Big polygon with holes (original);
2. Polygons of holes.

Probably it's becouse ST_Polygonize can't "know" if a multilinestring represents a polygon with holes or a set of polygons.

If you compare original polygon with ST_GeometryN(geom,1) result of ST_Polygonize it will return TRUE.

Try:
SELECT ST_Equals(a.geom,p.geom)
 FROM areas a
	JOIN (SELECT id,ST_GeometryN(ST_Polygonize(ST_Boundary(geom)),1) geom FROM areas GROUP BY id) p USING(id)


Regards,
Marcin

On Sun, 03 Jun 2018 23:36:40 +0200, Paulo Pires <paulopires16 at gmail.com> wrote:

> Hello,
>
>
> Please, see this 2 polygons example.
>
> I Convert them to linestrings (ST_Boundary) and then to polygons again
> (ST_Polygonize) and I can't reach to same polygons...
>
> This is a bug from ST_Polygonize function?
>
> DROP TABLE IF EXISTS areas;
> CREATE TABLE areas (
> id integer,
> geom GEOMETRY
> );
>
> INSERT INTO areas (id, geom) VALUES
> (1, ST_GeometryFromText('POLYGON (( 152475.78309656942
> 348633.83643648896 100.0 , 152819.11124438787 348634.30014856393 100.0
> , 152813.0950157867 348346.43594807677 100.0 , 151948.4678701025
> 348359.31090193643 100.0 , 151945.74402745243 348463.90645969921 100.0
> , 152474.91289439827 348458.49244305107 100.0 , 152475.78309656942
> 348633.83643648896 100.0 ), ( 152527.33647845959 348558.83199005033
> 100.0 , 152529.2307245445 348407.29230325681 100.0 ,
> 152709.18410261182 348403.50381108694 100.0 , 152709.18410261182
> 348558.83199005033 100.0 , 152527.33647845959 348558.83199005033 100.0
> ), ( 152006.95163549151 348435.14978348627 100.0 , 152006.95163549151
> 348385.89938685647 100.0 , 152092.19270658147 348384.00514083228 100.0
> , 152091.24558356937 348434.20266047411 100.0 , 152006.95163549151
> 348435.14978348627 100.0 ))')),
> (2, ST_GeometryFromText('POLYGON (( 152527.33647845959
> 348558.83199005033 100.0 , 152709.18410261182 348558.83199005033 100.0
> , 152709.18410261182 348403.50381108694 100.0 , 152529.22480595027
> 348407.76579079556 100.0 , 152527.33647845959 348558.83199005033 100.0
> ))'))
> ;
>
> DROP TABLE IF EXISTS poly2line;
> create table poly2line as
> SELECT ST_Boundary((ST_Dump(geom)).geom) AS geom
> FROM areas;
>
> DROP TABLE IF EXISTS polygonize;
> CREATE TABLE polygonize AS
> select (st_dump(ST_Polygonize(geom))).geom as geom
> from poly2line;
>
>
>
> Paulo Pires
>
> ------------------------------
> phone  964592113
> e-mail  paulopires16 at gmail.com
> crypt   myPGP public key for encryption emails
> <http://kerckhoffs.surfnet.nl/pks/lookup?op=get&search=0x878711213981EEF6>
> links    facebook <http://facebook.com/paulopires16> · twitter
> <http://twitter.com/#!/paulopires16> · linkedin
> <http://www.linkedin.com/pub/paulo-pires/36/4a7/607> · netlog
> <http://netlog.com/paulopires16> · javase
> <http://download.oracle.com/javase/6/docs/api/> · oracle
> <http://www.oracle.com/us/syndication/feeds/index.html>
> ------------------------------
>
> Aviso Legal:
> Esta mensagem de Paulo Pires é destinada exclusivamente ao destinatário.
> Pode conter informação confidencial ou legalmente protegida. A incorrecta
> transmissão desta mensagem não significa a perda de confidencialidade. Se
> esta mensagem for recebida por engano, por favor envie-a de volta para o
> remetente e apague-a do seu sistema de imediato. É proibido a qualquer
> pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte
> desta mensagem.
>
> Disclaimer:
> This message from Paulo Pires is destined exclusively to the intended
> receiver. It may contain confidential or legally protected information. The
> incorrect transmission of this message does not mean the loss of its
> confidentiality. If this message is received by mistake, please send it
> back to the sender and delete it from your system immediately. It is
> forbidden to any person who is not the intended receiver to use, distribute
> or copy any part of this message.


More information about the postgis-users mailing list