I have a strange error with a large complex polygon shapefile (representing a hypothetical historic flood level of a lake) that I cannot resolve. Using QGIS 2.18.14, the polygon was derived as follows...

  1. Reclassify a digital elevation model (DEM) into two classes- one class above the desired flood level, one below the desired flood level.
  2. Polygonize the class below the desired flood level (Raster--> Conversion--> Polygonize).
  3. Subsequently, I edited the geometry of the resulting polygon to merge small islands with the larger lake level polygon. I also adjusted some boundaries manually using the edit nodes tool.

Now, when I open the shapefile, toggle editing, and use the nodes tool, validation starts as usual, except that the entire polygon consists of duplicate nodes. Because the polygon is large and complex (~35,000 nodes), it takes some time to validate and is really inefficient to manually inspect. I've tried the following remedies:

  • Use the GRASS v.clean tool
  • Use the MMQGIS Modify--> Remove Duplicate Geometries Tool
  • Import the shapefile into SAGA and convert the polygon to edges + nodes, then subsequently remove duplicate points with the Shapes - Points--> Remove Duplicate Points tool
  • Export only the edges from the previous step, saving them as a polygon

None of these remedies seem to work. I've not been able to find this same problem posted elsewhere online. I would ordinarily give up at this point and try to re-create the flood level polygon to better document what may have caused it to go wrong along the way (I suspect something happened during my manual editing, but I can't imagine what). I put several hours into step 3 above (manual editing), and so it would be great if there was a way to solve this issue.

I included a link to download the shapefile below if anyone wishes to play with it.

p.s. - you may be tempted to criticize why I am even dealing with this type of analysis by converting an artificially flooded DEM into a polygon... it is a client's request to have the result as a shapefile.

Lake polygon download

  • Maybe a workaround could be to work with the raster>extract>contour tool. – LMB Mar 22 '18 at 20:26

It's easy to fix in QGIS 3.0. Just run the "Fix geometries" algorithm from the Processing Toolbox.


Try this. I would post how I did it, but it's an aberration of Python code mixing fiona, shapely, and gdal. Basically, I just extracted every other point vertex in your polygon shapefile. I should note that it was actually a multi-polygon and I did not preserve the smaller one--it appeared to simply overlap the northwest corner of the lake a little. Also, since I didn't check for exact duplicates, if any of your vertices did not have a duplicate, I may have removed it altogether. But it was quick and dirty.

  • Could you please post a solution which future readers could potentially use? – Aaron Mar 22 '18 at 21:28
  • I intentionally did not post the code solution because I truly solved it in a horrendous manner due to my lack of expertise with shapely/fiona. Just a nasty, ole Frankencode from cutting and pasting off Stackexchange questions. – Jon Mar 22 '18 at 21:51

It takes about 2 seconds to remove the duplicated nodes with OpenJUMP.

Use the Make Geometries Valid tool

enter image description here

Check the option to remove duplicate nodes

enter image description here

The original polygon had 79169 vertices and the processed one has 39380 so not quite every other vertex was removed.

A usual trick to simplify the geometry with tolarance of zero did not work for this geometry in OpenJUMP. You can still try if it happens to work with QGIS.

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.