Problem
I want to turn bathymetric lines into polygons. However, the bathymetric line datasets have multiple dangling ends within them. Because of this, the 'Lines to polygons' or 'Polygonize' tools in the QGIS 'Processing Toolbox' are unsuccessful.
Any lines that have dangling ends (of which there are many) result in missed polygons or whacky projections depending on the processing method used. I have solved the issue previously through a manual effort on a small dataset - but I am looking for a solution to clean large datasets by merging like attribute dangles (i.e. depth contour of 5m closes with the other end of the same 5m contour) to complete the line. Unfortunately, it is not feasible to manually fix dangling ends for an entire dataset given time restrictions and size of the datasets.
Dangling End Examples
I have identified the dangles through the 'Topology Checker' tool in QGIS (the red dots in above images). As you can see in those images, some dangles are extremely close together where others are much more separated. Ideally for the separated dangles, they will follow the line of the previous contour as they connect (but that might be asking for too much).
What have I tried?
I have tried things like; snapping the (0, -1) coordinates of the lines, using the snap geometries to layer tool, etc. Some solutions did successfully snap the line endpoints together, but they did not connect logically.
From my investigations I believe the answer could lie somewhere with the v.clean tool and the 'snap' cleaning tool within. Unfortunately, I haven't had any luck yet solving my problem with any of the parameters I have defined.
Data
If you are interested - you can download a sample shapefile here.
Summary
To reiterate - I am looking for a way to clean the dangles (by completing liked attribute contours) from the line string datasets so they can be converted in polygons. Doing so manually is not an option. Feel free to provide 'Processing Toolbox' or PyQGIS solutions - whichever you feel is easiest to set the necessary parameter's to solve this issue?


