[postgis-users] ST_Polygonize give different results on same set of linestrings

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Thu Sep 7 06:46:18 PDT 2017


Hi,

Is it normal that ST_Polygonize() gives two different results depending on if the linestrings are ST_Union() before calling it or not?

In the following example, test 1 (no union) and 3 (ST_Collect) give the same result, constructing two overlapping polygons. Test 2 (ST_Union) on the other side constructs 3 disjoint polygons removing overlaps. All tests provide, however, the same basic set of linestrings to ST_Polygonize.

WITH polys AS (
  SELECT ST_GeomFromText('POLYGON((1 1, 3 2, 3 0, 1 1))') geom
  UNION ALL
  SELECT ST_GeomFromText('POLYGON((2 1, 4 2, 4 0, 2 1))') geom
), extrings AS (
SELECT 1 test, ST_ExteriorRing(geom) geom
FROM polys
UNION ALL
SELECT 2 test, ST_Union(ST_ExteriorRing(geom)) geom
FROM polys
UNION ALL
SELECT 3 test, ST_Collect(ST_ExteriorRing(geom)) geom
FROM polys
)
SELECT test, ST_AsText(ST_Polygonize(geom))
FROM extrings
GROUP BY test;

It seems to me that only test 2 (ST_Union) returns the expected result which is to reconstruct planar polygons from a set of linestrings however they are provided.

It bothers me because I would like to get the same result as test 2 without relying on ST_Union() which seems to sometime slightly shift vertexes in order to union geometries together (true or false?).

Thanks for any explanation.

Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20170907/ef6332ff/attachment.html>


More information about the postgis-users mailing list