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?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Jan 27, 2017 at 14:00
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.

answered Apr 6, 2017 at 0:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.