polygonize_full operation, which merges line segments into polygons, returns four geometry collections: polygons, dangles, cuts and invalid ring lines. Dangles are defined in the documentation as "edges which have one or both ends which are not incident on another edge endpoint", while cuts are "connected at both ends but do not form part of polygon".
I assumed that the following code, which tries to polygonize a square with one edge missing, should find two dangles and one cut edge:
import shapely lines = [ ((0,0),(1,0)), ((1,0),(1,1)), ((1,1),(0,1)) ] polygons, dangles, cuts, invalids = shapely.ops.polygonize_full(lines)
invalids collections are all empty, while the
cuts collection contains the three original edges:
[str(cut) for cut in cuts] # This returns ['LINESTRING (1 1, 0 1)', 'LINESTRING (1 0, 1 1)', 'LINESTRING (0 0, 1 0)']
polygonize_full detect a dangle? Is there a way to get the dangling edges in my test case (
0 0, 1 0 and
1 1, 0 1) using Shapely?