Trying the v.clean command and checked the layer with Topology checker and it turned out every single geometry was invalid.

What to do now?

enter image description here

Original question:

I have two shapefiles with 3D building blocks that I want to merge (Both MultiPolygonZ-type, the same columns in attribute table with the same projection). The blocks represent houses in two different area of the city (no overlaps).

Vector > Data Management Tools > Merge vector layers works great except that some features in the merged file looses it's solidness, see example below:

Houses from one of the shapes before merge (all houses are solid):

enter image description here

The same canvas from the merged file (some features loose their solidness): enter image description here

Has anyone experienced the same problem and been able to workaround it?

Links below to two of the shape-files I'm trying to merge if anyone want to try and re-create the problem:

Dataset A: https://drive.google.com/open?id=0BwFHJFrNX33hbGFHS2ZCeUVJNWc

Dataset B: https://drive.google.com/open?id=0BwFHJFrNX33hZGFoT2xiVXZSbGs

  • Which QGIS version?
    – ndawson
    Nov 22, 2016 at 20:51
  • 2.18.0 Las Palmas
    – johlund
    Nov 22, 2016 at 20:52
  • The same problem occurs when saving one of the vector layers to re-project it to a different projection. Some of the solid blocks disappears as soon as qgis does anything with it.
    – johlund
    Nov 22, 2016 at 22:22
  • After the merge the type changed from MultipolygonZ to PolygonZ. Could that have something to do with it?
    – johlund
    Nov 22, 2016 at 22:26
  • Those links are only the .shp files - they are missing all the extra files which need to be zipped with the .shp file to make them usable.
    – ndawson
    Nov 22, 2016 at 22:32

1 Answer 1


I had the same issue dossolving polygons, the problem was that there were Geometry Errors. Bare in mind my process was a Standalone application, however the concept should help. Before performing the merge I ran

validate= processing.runalg("grass7:v.clean",CleanedOutput,0,0.1,extents,-1,0.0001,InFeature,errorsOutput)

This tool is simply a GRASS tool called v.clean, you can search for it from your processing toolbox. This tool cleans the geometry of the input vector layer, read about this more HERE

The different types of v.clean

If you don't trust the v.clean to solv the problems, You can also use the Check Geometry Validity from fTools plugin, to inspect the file manually, this tool will highlight all geometry errors, enter edit mode to solve the errors by deleting duplicate Nodes, Polygon overlaps etc.

Once the Geometry errors are dealt with the files should merge, dissolve, intersect, without losing features.

Another method I used was the GDAL tools ogr2ogr

To create a file to merge into use the following command. This will take a shapefile and copy it to a file called merge.shp (this filename is up to you).

ogr2ogr -f ‘ESRI Shapefile’ merge.shp filename1.shp
Then merge the following files by using:

ogr2ogr -f ‘ESRI Shapefile’ -update -append merge.shp filename2.shp -nln merge
ogr2ogr -f ‘ESRI Shapefile’ -update -append merge.shp filename3.shp -nln merge

read more here

*Note you need the OSGeo4W shell provided with the For Advanced Users Download * This should help defeat the geometry errors Hopefully this solves your issue, I remember how frustrating it was with me.


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.