0

In my QGIS projects I often have to append attributes from other spatially overlapping layers to a base dataset. E.g. I am working with a forest stand map and need add soil information, plant information or administrative details, usually a one-to-one relationship based on the largest overlap with each respective layer.

I am using the obvious "Join attributes by Location" tool for that, which has a major downside: It always wants to create a new file. I cannot append "in place", meaning appending columns resulting from the spatial join to my loaded dataset, kind of like creating new columns for the loaded stand map with Field Calculator.

Is there a way or a tool to perform a spatial join without creating a new file each time?


To elaborate: Currently to join three distinct layers to my base dataset, I do:

  1. Perform first join (stand_map.gpkg + soil_info) -> stand_map_join1_soil.gpkg
  2. Perform second join (stand_map_join1_soil.gpkg + plant_info) -> stand_map_join2_plant.gpkg
  3. Perform thrid join (stand_map_join2_plant.gpkg + admin_info) -> stand_map_join3_admin.gpkg
  4. Then close the project, manually replace my stand_map.gpkg with stand_map_join3_admin.gpkg: (backup), delete, copy/move new file and rename
  5. Open project again - now I've added the attributes "in place"

My thoughts so far:

  • Choosing the base dataset stand_map.gpkg as output is an option (i.e. overwriting it). This however requires it not being loaded (i.e. write-protected) in any QGIS project, meaning accessing it for the spatial join may be a bit circumstancial and implies loosing all project context just for the operation (i.e. closing the base data project you're currently working with). Also I fear that while overwriting a file, it first gets deleted. If something during the output goes wrong, the original will be lost, without a possibly corrupt output. So I think the overwrite option is bad practice and inconvenient.
  • The zonal statistics output dialog offers a "append to Layer" option, that sparked some hope. However I never got it to work (will have to add a question for that) and this option isn't available for spatial join either. Zonal statistics: Append to layer instead of save to file
  • There is an option to add "normal" (attribute/key-based) joins in the layer options... these are dynamic "in place" joins, but I don't see an option to have something similar for a spatial join.

Spatial join dialog

1
  • 1
    You can probably do this with an expression, maybe using overlay_nearest and attribute
    – Sethinacan
    Aug 17, 2023 at 7:39

1 Answer 1

0

I couldn't get the Append the layer work either, but I posted my workaround solution to this problem in a similar question here: How can I use the Zonal statistics "append to layer" functionality?

Basically, it only reduces the number of active steps and clicks you have to do, but still creates all of the intermediary shapefiles.

If someone else was able to get the "Append" option to work, would also love to know how!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.