TransWikia.com

ST_Polygonize/Shapely cannot polygonize when overlapping with shared node/point

Geographic Information Systems Asked by Kevin Redman on December 9, 2020

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))

One Answer

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

e.g.:

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

Answered by Subhrasankha Dey on December 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP