I am trying to fix topological errors in this Shapefile of small areas of a state (Bahia) in Brazil. After applying prepair and PPrepair, the resulting shapefile has some spikes:

enter image description here

It looks like a line from far, but when we zoom in we can see that the spike has some area:

enter image description here

Then I removed the spikes with a Postgis buffer function:

SELECT geom,
  ST_Buffer(  ST_Buffer(  ST_Buffer(geom,0.00001, 'join=mitre'),-0.00002,                           
  'join=mitre'),0.00001, 'join=mitre') AS geom_spike_removed
  FROM repaired_polygons;

resulting in this, (I overlayed the layer) and got some holes between polygons:

enter image description here

How do I remove the slivers so that the empty area is attributed to the nearest polygon?

The spike and subsequent sliver is about 0.071mm in width.

  • please make this more reproducible by adiing links to the original file, pprepair, the spike removal function in Postgis, related questions here Jul 17, 2018 at 17:49
  • also, It could be nice if you could add the file that contains the spikes (output from pprpair) and the id of the polygon with the spikes Jul 17, 2018 at 17:50
  • @LucasMation that's not likely feasible if the data cannot be shared Jul 17, 2018 at 17:58
  • Jader - how many polygons do you have to fix? QGIS has the Topology Checker plugin that you can use to determine how many issues you might have... could be a manual fix though Jul 17, 2018 at 17:59
  • 1
    @LucasMation nice in this case, but doesn't always need to be a requirement. Jul 17, 2018 at 18:13

1 Answer 1


I don't know how you got the data, but it's wrong, see the picture.enter image description here The errors are different, for example: self-intersections, absence of interfacing of polygons with each other, etc. As of 24139 only 20 broken, my suggestion is the following, 1) convert the multipolygons to polygons, 2) Use the function ST_SnapToGrid PostGIS, with a tolerance of 3) Remove the broken polygons that create the outer polygon and cut out its "proper polygon" :-), and add to your layer...such actions will allow you to bring your data in order...By the way, for some reason QGIS does not show me problems with your data, although in fact they are...

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.