Is there a way to export a list of layers containing invalid geometry (e.g. self-intersections) via Python?
Our GIS server contains over 40,000 layers, some of which have all sorts of errors that simply cannot be identified manually.
Is there some sort of OGR/GDAL command that can perform this?
1 Answer 1
You may want to check out shapely library. You can loop ever the features and check the is_valid propery. This is from the docs:
object.is_valid Returns True if a feature is "valid" in the sense of 1.
A valid LinearRing may not cross itself or touch itself at a single point. A valid Polygon may not possess any overlapping exterior or interior rings. A valid MultiPolygon may not collect any overlapping polygons. Operations on invalid features may fail.
Explore related questions
See similar questions with these tags.
-sql "select * from filename WHERE not ST_IsValid(geometry)"
. Otherwise mass converting to sqlite or postgis and using the abilities of these formats might work.