1

So I have a list of farms (points), and three other layers of catchment zones (polygons). I want to add to the farm list's data table which catchment zones the farms fall into. As there are multiple catchments I was thinking of adding a new column for each one, but I'm not sure how to append information to the list of farms. Currently using QGIS 3.16

Vince
  • 20,017
  • 15
  • 45
  • 64

1 Answers1

2

possible duplicate of How to handle many to many relationship?, with an answer here.

From your question it was unclear if a farm can belong to multiple catchments or only one. So here is the answer for both:

only one catchment per farm (one-to-many)

Answer adapted from here non-overlapping catchment polygons with farms inside different polygons Simply use the Join attributes by location tool: Join attributes by location in the processing toolbox

Set "Farms" as Base layer and "Catchments" as Join layer:

Base layer Farms and Join layer catchments

The resulting map should have all fields from your catchment attached to the farm. You can also specify which fields to add.

farms on catchments, where farms on the same catchment have the same color

multiple catchments per farm (many-to-many)

If there are multiple catchments, a farm can belong to, this is a many-to-many relationship. In SQL (which a GeoPackage is), these are handled by a separate table that has rows that match a farm to a catchment, like:

FARM_NAME CATCHMENT_NAME
Jan one
Henk one
Henk three

note Ideally you would be using IDs in stead of names. See this answer for how to create id columns.

Simply run the Join attributes by location algorithm again like before. Make sure Join type is set to create separate feature for each matching feature (one-to-many).

enter image description here

As you can see, there are multiple points generated for farms that lie within multiple polygons. (Henk, Kees, Klaas, Pieter). If your catchments had any data attached, this will also be attached to each of the farms.

Depending on what you further want to do, you could Drop geometries of the joined layer, change data in the farms layer and later use the dropped geometries table to perform two join attributes by field value to join the catchments back to the farms or just use a Join attributes by location again.

Fee
  • 1,158
  • 4
  • 14