0

I wonder if it is possible to check the geometry of multiple polygons using Fiona or shapely library In Python. Whichever polygon does have proper geometry will be kept and the rest will be deleted and a list of polygon names with whether they have correct geometry and not correct geometry be printed.

Problem Statement: I have more than 200 polygons, out of these polygons, some polygons don't have the correct geometry, i.e. in the below-attached image ID, 19200102 polygon doesn't have geometry information. I want to filter out, want to keep only which polygons have the correct geometry. Print the name of polygons correct and not correct geometry.

enter image description here

0

2 Answers 2

3

In shapely there is an unary operation that validate if a geometry is valid. See Shapely documentation for more information. See OGC document: Simple Feature Access - Part 1: Common Architecture for the definitions of what is a valid Point, LineString, Polygon and all the multi combination.

In Shapely the command to validate a spatial object is:

object.is_valid

For the display of the attributes, Fiona keeps a copy of the attributes in a dictionary. Look at the documentation, should be easy to find.

0

You could try the checkvalidity tool, which is accessible from QGIS, this will give you three layers:

1- Valid

2- Invalid

3- Errors

Below is a snapshot of the GUI and the background code is accessible at the following link:

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.