Bug report #19708

Processing: Join attributes by location produces duplicated fid

Added by Jérôme Guélat almost 2 years ago. Updated almost 2 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/QGIS
Affected QGIS version:3.2.2 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27533

Description

Here's how to reproduce the bug:

1. Add the 2 layers (pol1 and pol2) from the attached GeoPackage
2. In Processing, open Join attributes by location
3. Input layer: pol1; join layer: pol2; geometric predicate: within
4. Don't specify an output file (use a temporary layer)
5. The resulting layer will have 2 features with the same fid, and hence can't be saved to a new GeoPackage without manually editing the fid values
6. If you save directly to a GeoPackage (instead of using a temporary layer), one feature will be lost. Suprisingly, this doesn't happen if you save directly to a Shapefile

I know it is uncommon to use a spatial join with perfectly overlapping geometries in the joined layer, but it would be nice to have a consistent behaviour between different output formats.

testgeom.gpkg - Sample data (136 KB) Jérôme Guélat, 2018-08-27 03:27 PM


Related issues

Related to QGIS Application - Bug report #19758: Processing: merge vector layers produces duplicated fid Open 2018-09-03
Related to QGIS Application - Bug report #19998: Cannot export output of 'Points along geometry' tool as G... Closed 2018-10-02

Associated revisions

Revision f8d873c7
Added by Matthias Kuhn almost 2 years ago

Regenerate fids for "join attributes by location"

Fix #19708

Revision 1d474d8e
Added by Matthias Kuhn almost 2 years ago

Regenerate fids for "join attributes by location"

Fix #19708

History

#1 Updated by Jérôme Guélat almost 2 years ago

Note that something similar happens with the Intersection algorithm (and maybe with other algorithms based on overlays).

#2 Updated by Giovanni Manghi almost 2 years ago

  • Operating System deleted (Windows 7)

Confirmed here. I think that especially the result of the operation 6 ("If you save directly to a GeoPackage (instead of using a temporary layer), one feature will be lost") is particularly problematic.

#3 Updated by Jérôme Guélat almost 2 years ago

After further testing, this also applies when the geometries are not perfectly overlapping (use intersect instead of within as a geometric predicate)... The problem happens when one feature from the input layer has at least 2 intersecting features in the join layer (and we perform a one-to-many spatial join).

See also #19758

#4 Updated by Andrea Giudiceandrea almost 2 years ago

  • Related to Bug report #19758: Processing: merge vector layers produces duplicated fid added

#5 Updated by Andrea Giudiceandrea almost 2 years ago

  • Related to Bug report #19998: Cannot export output of 'Points along geometry' tool as Geopackage added

#6 Updated by Matthias Kuhn almost 2 years ago

  • Status changed from Open to In Progress

#7 Updated by Anonymous almost 2 years ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

Also available in: Atom PDF