Polygonize after simplifying ways fails

11 views
Skip to first unread message

ckgoo...@gmail.com

unread,
Dec 12, 2025, 4:55:06 PM (4 days ago) Dec 12
to spatiali...@googlegroups.com

Hi.  I have a table of LINESTRING geometries  and I aggregate them into the Polygonize function to get a polygon geometry.  If I use the Simplify function on the LINESTRINGS to reduce the number of points I am getting cases where  Polygonize returns -1.

I did find there was an E-09 difference in the y values from the original start and end points  between my original and simplified LINESTRINGS but I updated my simplified geometry  back to have original values for these two points but Polygonize still fails.

I am not completely sure, but it feels impossible that a polygon made up of LINESTRINGS will become invalid if the constituent lines are simplified.

Does anyone have any thoughts on why I am getting these Polygonize failures?

Unfortunately I’m unable to visualise the simplified LINESTRINGS as I’m blind.

Best, Chris

sandro furieri

unread,
Dec 13, 2025, 12:51:28 AM (4 days ago) Dec 13
to spatiali...@googlegroups.com, ckgoo...@gmail.com
Il 2025-12-12 22:54 ckgoo...@gmail.com ha scritto:
> I am not completely sure, but it feels impossible that a polygon made
> up of LINESTRINGS will become invalid if the constituent lines are
> simplified.
>
> Does anyone have any thoughts on why I am getting these Polygonize
> failures?
>

Hi Chris,

There are some important differences between LINESTRINGs and POLYGON
RINGs.

1) a LINESTRING is valid if it has at least two points; there are
no other requirements.

2) a RING instead has much more stringent requirements:
* must form a closed figure, with the first and last points
coinciding.
* there must be no points of self-intersection (hourglass
figures).
* there must never be overlapping segments.
* must not contain spikes.

When you apply ST_Simplify() to your Linestrings it is very
likely that the modified geometries will then violate some
requirement that prohibits creating a valid RING.

I don't know if your POLYGON contain internal holes;
in this case, a further requirement arises: the internal
RINGs can never intersect the external one, they must
necessarily be completely contained within it.
It is quite evident that the upstream simplification
of the Linestrings could easily create violations of
this constraint.

Note that there are two different functions:
- ST_Simplify() which is suitable for Linestrings
- ST_SimpplifyPreserveTopolog() it's instead made
specifically for Polygons, and ensures that no
violations occur regarding the internal Rings.

Conclusions: It's the very idea of ​​simplifying
Linestrings in advance that is conceptually flawed,
because this way you are ignoring all the constraints
required by Polygon Rings.

The only consistent approach is to first aggregate
all the Linestrings, and only at the end simplify
the Polygon.
Possibly using ST_SimplifyPreserveTopology() and
not the simple ST_Simplify()

best regards,
Sandro
Reply all
Reply to author
Forward
0 new messages