Skip to main content
68 votes

Identifying duplicate attributes in field using QGIS

Another graphical, dynamic and most importantly simple way to detect duplicate attributes: use QGIS's expression builder. Highlight duplicates in attribute table: Suppose FieldWithDuplicates is the ...
she_weeds's user avatar
  • 13k
22 votes

Duplicating layer in memory using PyQGIS

In QGIS 3 you can make a copy of a layer without saving any reference to the parent layer in this way: # imports import processing from qgis.utils import iface from qgis.core import QgsProject # ...
Leo Cardona's user avatar
  • 1,383
14 votes
Accepted

Labeling only one duplicate attribute without editing original data in QGIS

You can achieve something like in the picture just below by using some expressions without editing any of your data. Just use them as they are. Follow the steps below and adjust them to your personal ...
MrXsquared's user avatar
  • 35.6k
13 votes

Identifying duplicate attributes in field using QGIS

I'm wondering why didn't anybody recommend to use only the Select By Expression tool with the query: COUNT(1, "attribute")>1 Then all features with repeated attribute will be selected, ...
caiohamamura's user avatar
  • 1,051
9 votes

Deleting duplicate points except those with different attributes in QGIS?

You may run this code (just copy-and-paste it in the Python Console): layer = iface.activeLayer() # This command will load the layer currently selected # Create the output layer crs = layer.crs()....
mgri's user avatar
  • 16.3k
8 votes

Delete duplicate points in QGIS

I recommend you to use, delete duplicate geometries, you will find this process, in the process toolbox, in the General Vector options. If, for some reason fail, you have a similar process in SAGA, in ...
Luis Perez's user avatar
  • 1,304
8 votes
Accepted

Creating duplicate points as many times as it overlap with polygons in QGIS

The "Join Attributes by Location" tool, with a 'one-to-many' join type, should give your desired result.
Matt's user avatar
  • 17.9k
8 votes
Accepted

Aggregating features values based on name attribute and geometry in QGIS

Instead of using logical operator AND, try the ||-joint: geom_to_wkt($geometry) || "name"
Taras's user avatar
  • 34k
7 votes
Accepted

Deleting duplicate records in the attribute table and keep the minimum value in PyQGIS?

If I understand your question, you may use the following code: layer= iface.activeLayer() # load the layer as you want vals = {} # create an empty dictionary # Let's populate the dictionary for feat ...
mgri's user avatar
  • 16.3k
7 votes

Duplicating layer in memory using PyQGIS

Since QGIS 3.0 there is another approach available. Use the materialize() method from the QgsFeatureSource class. Over the entire layer with the allFeatureIds() method: # imports from qgis.utils ...
Taras's user avatar
  • 34k
7 votes
Accepted

How to select duplicate records based on multiple fields?

I was faced with a similar problem today, but I ended up using FME which was really quick and easy. What I was thinking was an update cursor which loops through the rows. Store the row in a list. ...
Fezter's user avatar
  • 22k
7 votes
Accepted

Identifying duplicate geometries in different layers with QGIS

The following code actually does what I want: CASE WHEN overlay_equals('LIC') = 1 THEN 'yes' ELSE NULL END Another option could be obtaining a 0/1 return, setting an integer field with the ...
jpinilla's user avatar
  • 3,240
7 votes
Accepted

Adding duplicate labels within polygon in QGIS

Go to the Layer Properties > Symbology and set the Symbol by Fill > Point Pattern Fill > Marker > Font Marker. Then scroll down to find Data Defined Override (small dropdown icon) next to ...
Kazuhito's user avatar
  • 31.2k
7 votes
Accepted

Redistributing duplicated points inside the polygon

Here is how you can do this using a PyQGIS script. Open the Python-Console, copy paste the code, change your settings at the top of the code and hit run. You can also cancel the execution via QGIS-...
MrXsquared's user avatar
  • 35.6k
7 votes

Redistributing duplicated points inside the polygon

If you have a PostgreSQL BD with PostGIS, you can do the following query : SELECT a.*, ST_GeneratePoints(b.geom, 1, floor(random() * 5000 + 1)::int) AS new_address_geom FROM addresses a, ...
J. Monticolo's user avatar
  • 15.9k
6 votes
Accepted

Removing duplicate rows created by ST_Intersects in PostGIS?

If you add DISTINCT to your select statement that should return what you are looking for. Try: CREATE TABLE test_table AS SELECT DISTINCT parcels.*, COALESCE(ST_Intersects(parcels.wkb_geometry, ...
Cushen's user avatar
  • 3,197
6 votes
Accepted

Selecting duplicates records except one in QGIS

In QGIS you can use "Select by expression" with this expression: array_contains( array_remove_at( array_agg($id, "field"), 0), $id) It will select all ...
MrXsquared's user avatar
  • 35.6k
6 votes
Accepted

Removing intersect or overlap of points in the same vector layer

One way of doing it, which could work: DBscan Clustering to give each cluster of nearby points a cluster ID, adjust maximum distance: Delete duplicates by attribute by cluster ID:
Bera's user avatar
  • 77.8k
6 votes

Eliminating duplicates only if data is the same according to attributes

You have two options, depending on whether the points are actual duplicates (exactely the same point) or if the are "almost" duplicates (very close to one another): Use Menu Processing / ...
Babel's user avatar
  • 74.9k
6 votes

Hiding duplicates from dropdown when using value relation in QGIS Form

You can use the Value Map form widget to have a list of unique items, even from a field with duplicate values. From the documentation : Value Map: A combo box with predefined items. The value is ...
J. Monticolo's user avatar
  • 15.9k
6 votes

Deleting NULL geometries and duplicate nodes from table using PostGIS

This requires a procedural execution of dynamic SQL - best applied with a DO block. Since we are only looking at modifying columns of type GEOMETRY, we can identify the respective relations easily ...
geozelot's user avatar
  • 30.9k
5 votes
Accepted

increment column value with an integer when it is a duplicate

QGIS 3.0/3.2 (1) Use Add autoincremental field tool (in Processing Toolbox | Vector table) to create new incremental number field. Input layer: your layer Field name: any name (default value is AUTO)...
Kazuhito's user avatar
  • 31.2k
5 votes
Accepted

Duplicating of QgsLayoutItemGroup with PyQGIS

The copy/paste mechanism for layout items is implemented in the QgsLayoutView class (copyItems, pasteItems). I'm not sure if there's a way to use these functions without opening and accessing the ...
Jake's user avatar
  • 6,934
5 votes

Selecting duplicate records except the first and last duplicate with Select by expression in QGIS

You can use this with select by expression: with_variable('arr',array_agg($id, "myfield"), if($id in (@arr[0],@arr[-1]),false,true)) Or for older QGIS versions where index brackets are not ...
MrXsquared's user avatar
  • 35.6k
5 votes

Removing duplicates from the Attribute table by expression in QGIS

Let's say you have duplicate values in field "value" and want to keep just one of the duplicate: the one with the smallest "id" value: use "Select by expression" with ...
Babel's user avatar
  • 74.9k
5 votes
Accepted

Removing duplicates from the Attribute table by expression in QGIS

It is not an expression, but there is a tool in QGIS for deleting duplicates called "Delete duplicates by attribute". Deletes duplicate rows by only considering the specified field / fields....
Taras's user avatar
  • 34k
5 votes

Hiding duplicates from dropdown when using value relation in QGIS Form

The answer by @J.Monticolo should be correct. Additionally, your data may be the source of the problem if there are blank spaces hidden in the values. For example, your values may include 'abc', ' ...
Stu Smith's user avatar
  • 8,386
5 votes

Hiding duplicates from dropdown when using value relation in QGIS Form

"fid" = array_first(array_agg("fid", group_by:="Direction"))
Rii Pii's user avatar
  • 486
5 votes
Accepted

Avoiding label identical attributes on duplicate geometries in QGIS

This is not optimal, but I was only able to find this solution. It would be better to call it a workaround. It may display a different result for your data. array_to_string( array_distinct( ...
Kadir Şahbaz's user avatar
4 votes

Deleting duplicate geometry in PostGIS tables

A more general answer to easily delete geometry duplicates in PostGIS table. The following command deletes all features with duplicate geometry in "table_name" based on primary key (column &...
Miro's user avatar
  • 9,794

Only top scored, non community-wiki answers of a minimum length are eligible