qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.6k stars 3.01k forks source link

Processing algorithm "Join by location" skips output values when there are conflisting column names #45054

Open tschmetzer opened 3 years ago

tschmetzer commented 3 years ago

What is the bug or the crash?

When two layers are processed using the algorithm "Join by location" then the base layer's attribute is assigned the value "NULL"

join_by_location_Mellia_PopValue join_by_location_Mellia_joinedValue

The problem occurs only when shapefile layers are used as input and a geopackage as output. There seems to be a type conversion problem from shapefile to Geopackage When the Geopackage format was input as well as output the problem wasn't reproducible. Same for pure shapefile conversions or when using a temporal layer.

Steps to reproduce the issue

  1. Insert the files Pop_Density_per_sqkm_Mollweide_Points_lt0_Melilla.dbf and GHS_SMOD_lt0_raster2points_withoutNoData_Melilla.dbf from the archive smod_pop_test.zip into a new project
  2. Open the processing dialog "Join attributues by location"
  3. Select the Pop_Density_per_sqkm_Mollweide_Points_lt0_Melilla as first (base) layer and the GHS_SMOD_lt0_raster2points_withoutNoData_Melilla as second (join) layer with join type "Take attributes from the first matching feature only (one-to-one)"

join_by_location_Mellia_dialog

  1. Select a GPKG as joined layer output

  2. Run the processing. It should finish in 1-2 s.

  3. Observe the results: Input join_by_location_Mellia_PopValue join_by_location_Mellia_SMODValue Ouput join_by_location_Mellia_joinedValue

Versions

QGIS version 3.20.2-Odense QGIS code revision 9f59a156 Qt version 5.15.2 Python version 3.9.5 GDAL/OGR version 3.3.1 PROJ version 8.1.0 EPSG Registry database version v10.027 (2021-06-17) GEOS version 3.9.1-CAPI-1.14.2 SQLite version 3.35.2 PDAL version 2.3.0 PostgreSQL client version 13.0 SpatiaLite version 5.0.1 QWT version 6.1.3 QScintilla2 version 2.11.5 OS version Windows 10 Version 2009

Active Python plugins GroupStats QuickOSM db_manager MetaSearch processing

Supported QGIS version

New profile

Additional context

No response

agiudiceandrea commented 3 years ago

@tschmetzer does the issue occur setting a "Joined field prefix"? Does the issue occur selecting only the "smod" field and unselecting the "fid" field in the "Fields to add" option?

I think the issue could be related to a typical field name conflict with GeoPackages, since the "Join Layer" has a "fid" field and the GeoPackage layer creation process also adds a "fid" field by default.

tschmetzer commented 3 years ago

@tschmetzer does the issue occur setting a "Joined field prefix"? Does the issue occur selecting only the "smod" field and unselecting the "fid" field in the "Fields to add" option?

image image

I think the issue could be related to a typical field name conflict with GeoPackages, since the "Join Layer" has a "fid" field and the GeoPackage layer creation process also adds a "fid" field by default.

It really seems to be a field name conflict that in my opinion the user needs to be warned of and if confirmed by the user it needs to be overwritten without other attributes being NULLed. What's your opinion?