Take the 2-minute tour ×

I have a point shapefile with thousand of points. It has an ID code field that supposed to be unique. Every now and then the data entry clerk wrongly type the id creating duplicates.Right now I'm manually scrolling the field to find the duplicate.Is there a sane way to do this using the Search Query Builder ? Thanks for any help.

share|improve this question
If you need to enforce uniqueness I would recommend using a database e.g. Postgres/PostGIS, Spatailite –  Nathan W Jun 20 '12 at 10:26

5 Answers 5

up vote 3 down vote accepted

If the IDs are consecutive, I would add a new temporary column with unique values like @Ship.shp suggested and then use the query builder to search for ID != uniqueID.

That would return the duplicates directly. After fixing the original IDs, remove the extra column or repeat the whole process as needed — it is not clear what kind of pattern your IDs must match. If they just need to be unique, note the last value first and you can then edit the bad IDs in one iteration, just bumping the number as you go.

share|improve this answer

Use Group Stats plugin and set the ID as a field classification. You can see how many times each value has been entered in 'count' column.

share|improve this answer

A quick (although inelegant) way to do this is to go into Layer properties, select Style - Categorized using the column that you're interested in. Apply this, then right click on the layer in the layers window and check the Show Feature Count checkbox. Then expand the layer in the layers window and you can immediately see how many times each value has been entered.

share|improve this answer

Also you can use the split by attribute and end up with a seperate table for each value.

I like Rayo's suggestion though. except statist doesn't quite work like I thought it did.
It does give a count of unique values but doesn't help with what those values are.
Another software might add a count field and allow you to export it to csv or other spreadsheet format.

My suggestion for the split layer by attribute is in the vector management tools
management too

split your data on any 1 field an dyou will have your counts.
way more inelegant than ship.ship's solution

share|improve this answer
Please consider upvoting the answers you like! –  whuber Jun 20 '12 at 18:58
self upvote is not allowed! –  Brad Nesom Nov 20 '12 at 16:35

Yeah I banged my head against the wall for similar problem.

Here is my script for removing features with same ID's. It takes first feature with more than one index attribute and writes it to new feature class.

#Definition of inputs and outputs
# Written by: Gregor Skrt 
##[Example scripts]=group
##unique_field=field input
##output=output vector

#Algorithm body
from qgis.core import *
from PyQt4.QtCore import *
from processing.core.VectorWriter import VectorWriter

# "input" contains the location of the selected layer.
# We get the actual object, so we can get its bounds
layer = processing.getobject(input)
provider = layer.dataProvider()
fields = provider.fields()
writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() )

inFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0
values = {}

value_field_index = layer.fieldNameIndex(unique_field)

feats = processing.getfeatures(layer)
nFeat = len(feats)

for inFeat in feats:
    progress.setPercentage(int((100 * nElement)/nFeat))
    nElement += 1
    inGeom = inFeat.geometry()
    attrs = inFeat.attributes()
    value = attrs[value_field_index]

    if value not in values:
    #to ne vem ce bo drzalo ???
del writer
share|improve this answer

Your Answer


