4

I am pretty new with QGIS and GIS in general.

The thing is I have 2 shapefiles, the first one with municipalities (2457 polygons) and the second one with hydrological regions (363 polygons). I need to know which municipalities are inside which hydrological region. The shp with the hydrological regions has a column with an ID (HR1, HR2, etc.).

How can I add that value to each municipality?

3
  • Do you mean graphically, as you are just going to view one layer on top of another or do you mean you need an output from a tool in the processing toolbox?
    – Cary H
    Commented Sep 22, 2020 at 15:33
  • Is each municipality within only one hydrological regions? Commented Sep 22, 2020 at 15:35
  • Thank you both! I need an output with this information, and yes, each municipality is within only one hydrological region Commented Sep 22, 2020 at 15:41

2 Answers 2

6

You can use Vector general > Join Attributes by Location tool in Processing Toolbox(Ctrl+Alt+T).

  1. Set Input layer to municipality layer
  2. Set Join layer to hydrological regions layer
  3. Select within only
  4. Select only ID field in Multiple selection window
  5. Set Join type to Take attributes of the first matching feature only (one-to-one) and run the tool

enter image description here

2

You can use the tool join attributes by location : https://docs.qgis.org/3.10/en/docs/user_manual/processing_algs/qgis/vectorgeneral.html#join-attributes-by-location

He is located in the tab Vector -> Data Management Tool

It allows you to choose 2 layers and the spatial relation to join attribute from one layer to the other (intersect, touches, within, etc...). You can also choose the column to join.

In the pictue layer_A will be your municipalities, layer_B your Hydrological Regions and the Geometric predicate is within. So every municipalities obtain the ID of the Hydrological Regions they are in.

tool

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.