3

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?

2
  • For layers that are in a dataset where gdal can do sql-queries you might be able to query a condition -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. Commented Jan 27, 2017 at 14:25
  • Please edit the question to specify the data format in question. Commented Jan 28, 2017 at 3:54

1 Answer 1

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.