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