Postgis allows using
ST_Polygonize() from GEOS to make polygons out of lines. I have seen the same function available in Shapely library for Python, but in Shapely, the other method named
polygonize_full() is also available.
In PostgreSQL 10.1 + PostGIS 2.3.0, I would do something like this:
SELECT (ST_Dump(foofoo.polycoll)).geom AS geomtextrep FROM (SELECT ST_Polygonize(wkb_geometry) AS polycoll FROM (SELECT wkb_geometry FROM the_table WHERE ST_GeometryType(wkb_geometry) = 'ST_LineString') AS foo) AS foofoo;
In Python3 + Shapely, I would do something like this:
result, dangles, cuts, invalids = polygonize_full(lines)
I have seen in the GEOS library that there are two functions:
GEOSPolygonize_full - Returns polygons, dangles, cuts, invalid rings GEOSPolygonize - Returns only polygons
Is there any way to replicate the behaviour of GEOSPolygonize_full with PostGIS? I would like to use the dangles, cuts and invalids to judge whether I have missed out on some lines in the input data, and flag these events so I can manually check the source files (AutoCAD drawings) and associated layers.
I would hope ST_Polygonize_Full() maybe existed in PostGIS, but as far as I can see, it does not.