I'm trying to use both polygonize_full (Shapely, python) and ST_Polygonize (postgis) to get all polygons from a set of line strings.

There is one case where it fails: when there is an "overlapping polygon" with a shared "node".

Pictured here: https://puu.sh/DaVkp/0848ce181a.png

The result set is empty, but shapely provides a 'dangles' that provides the entire "failed" linestring,

Has anyone encountered this? Is there a way to gracefully solve this? I couldn't find anything in the docs.

I would expect these two be two separate polygons that overlap each other, despite their shared node.

Here's the WKT I'm using for example.

MULTILINESTRING((-122.43682090001732 37.767652910517015,-122.4366733785215 37.767652910517015),(-122.4366733785215 37.767652910517015,-122.4366733785215 37.76759990327466),(-122.4366733785215 37.76759990327466,-122.43682090001732 37.76759990327466),(-122.43682090001732 37.76759990327466,-122.43682090001732 37.767652910517015),(-122.43682090001732 37.767652910517015,-122.43675920920998 37.767717579352684),(-122.43675920920998 37.767717579352684,-122.43675920920998 37.767626406895836),(-122.43675920920998 37.767626406895836,-122.43682090001732 37.767652910517015))
  • 1
    Please use the SE UI to embed pictures. Links to third-party sites are more likely to fail, and less likely to be followed.
    – Vince
    Apr 6, 2019 at 23:43

1 Answer 1


You may try using shapely.ops.unary_union() before polygonize your multistring.


GoodMultistring= shapely.ops.unary_union(BadMultistring)
polygons = shapely.ops.polygonize(GoodMultistring)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.