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 ...
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
# ...
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 ...
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, ...
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()....
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 ...
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.
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"
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 ...
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 ...
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. ...
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 ...
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 ...
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-...
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,
...
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, ...
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 ...
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:
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 / ...
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 ...
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 ...
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)...
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 ...
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 ...
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 ...
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....
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', ' ...
5
votes
Hiding duplicates from dropdown when using value relation in QGIS Form
"fid" = array_first(array_agg("fid", group_by:="Direction"))
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(
...
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 &...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
duplication × 121qgis × 52
arcgis-desktop × 16
attribute-table × 14
postgis × 11
point × 9
layers × 8
geometry × 8
fields-attributes × 8
pyqgis × 7
labeling × 7
overlapping-features × 7
expression × 7
qgis-3 × 6
python × 5
arcpy × 5
line × 5
print-composer × 5
delete × 4
arcmap × 3
shapefile × 3
r × 3
postgresql × 3
openlayers × 3
arcgis-10.2 × 3