I am processing a large map with several hundred thousand building polygons in QGIS 2.18. Unfortunately I had to puzzle this map together from several smaller and overlapping pieces and so quite a few of them appear multiple times. Since I need to aggregate the building data later I need to get rid of the multiple polygons now.
The Polygons all have ID’s (string, non-consecutive) and so I hoped it would be possible to filter out the duplicates in the attribute table. I found a python script under Identify duplicate attributes which (as far as I understand it) should be a simple and elegant solution
from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def FindDublicate(IDfield, feature, parent): uniqueList =  if IDfield in uniqueList: return 1 else: uniqueList.append(IDfield) return 0
However, it does not work for me: The return is always ‘0’.
Can somebody tell me how the script should be such that it works under QGIS 2.18.1 or if there is an alternative solution to the problem?
Sidenote: I also tried several methods to clean the geometry but none of them worked: GRASS GIS 7 function v.clean does not show any effect, and MMQGIS delete duplicate tool simply leads to QGIS crashing.