Is there a R or Python solution that 1) checks the geometry validity of vectors and 2) outputs the results in form of a table (see table below). QGIS for example has a nice plugin that carries out several geometry checks. But how can I carry out these checks within a R or Python script?

enter image description here


In R there is package cleangeo for geometry checking and celaning. You can use for example:

report <- clgeo_CollectionReport(spatial_object)

#returns a table:

            type valid    issue_type
1           <NA>  TRUE          <NA>
2 rgeos_validity FALSE GEOM_VALIDITY
3    rgeos_error FALSE ORPHANED_HOLE
1                                                                                       <NA>
2                                                                                       <NA>
3 rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 7
1                                                                     <NA>
2 Ring Self-intersection at or near point -120.78997488 38.344996299999998


for summary you can do something like this:

NA's         :1 
  • I came along this package during my search but found it a bit limiting in comparison to the qgis plugin mentioned above. I feel that the qgis plugin allows me to check my geometries more thoroughly. Especially as I cannot seem to find duplicates, overlaps, minimum area polygons etc. What is your experience? – kalakaru May 25 at 7:02
  • 2
    You could use RQGIS to call the QGIS plugin directly maybe? – TimSalabim May 25 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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