But note that now there's a LINESTRING that wasn't part of the GeometryCollection before; the input was all of one type, MULTIPOLYGON. So the input is correctly noted to be invalid, and is made valid, but now the input has a surprising type.
Then note how small the LINESTRING geometry part is. If we apply a buffer of 0 after make_valid, we get a cleaner output that does not cause later exceptions to be raised: geometry.buffer(0)
Invalid input:
shapely.validation.explain_validity
:Too few points in geometry component[3119438.52529205 7571402.36771366]
The result of
shapely.validation.make_valid
:But note that now there's a
LINESTRING
that wasn't part of the GeometryCollection before; the input was all of one type,MULTIPOLYGON
. So the input is correctly noted to be invalid, and is made valid, but now the input has a surprising type.Then note how small the
LINESTRING
geometry part is. If we apply a buffer of 0 aftermake_valid
, we get a cleaner output that does not cause later exceptions to be raised:geometry.buffer(0)
And we're also back to a single Polygon.
Shapely notes:
I think that's an appropriate thing to do to any input polygon that we're already modifying with
make_valid
.