2

I got CSV data on analysed buildings containing object ID, materials etc. And I have vector file with spatial location of all buildings in the city containing as well object ID and some other attributes.

But issues is that in CSV table some object IDs are the same as for example some buildings have additional storage/shred but with different materials therefore different values. Example:

enter image description here

So when I join table to the vector layer, the join only recognises the value of one row even though in the vector layer there are same object IDs. Example:

enter image description here

I tried to give and new ID with row number but the problem is in vector layer I have more buildings then in CSV file so again the values are not connecting with corresponding buildings. Any other solutions?

1 Answer 1

1

If I understand correctly, you are asking two questions:

  1. You have multiple csv records for a given property, but the join only recognizes one csv record for that property:

This is because joins will connect only one record from the related table (typically the first related record the software comes across). This is the nature of joins, regardless of the software.

You, however, have a different situation, commonly known as one-to-many; that is, you potentially have many csv records that are related to one property. Your solution is to use relations instead of a join. Within QGIS use Project > Properties > Relations. For more information, search GIS SE for the term "QGIS one to many" or "QGIS relations".

  1. "... in vector layer I have more buildings then in CSV file so again the values are not connecting with corresponding buildings.":

If there are more building records than csv records, logic therefore states that some buildings will not have corresponding csv record(s) - and thus no joined records. For example, if your vector layer has three buildings (A, B, C) but you csv table has only two records (A, B), then there is nothing to connect with building C. It cannot be any other way.

6
  • Hi, thank you @StuSmith for your answer I did not know about this function. So when I do the relation part it is show in the project > properties > relation. Then I followed what instruction says in the [link] (docs.qgis.org/testing/en/docs/user_manual/working_with_vector/….
    – Julija M
    Commented Aug 13, 2019 at 9:01
  • I checked the info of one feature and the relation shows (3 corresponding object ID from the csv file), but in the attribute table it is not available the same info and I cannot edit neither in the info or in attribute table. The info is only available in the form view but I am not sure how I can do the calculations with that? Did I missed something or I am doing something wrong? I am mac user on qgis 3.6.
    – Julija M
    Commented Aug 13, 2019 at 9:01
  • My intention is to have all the info in the attribute table on the materials for each building as those are important for further calculations and intersections with other layers.
    – Julija M
    Commented Aug 13, 2019 at 9:04
  • @Julia M The instructions for viewing and editing are in the link that you posted above. Go to the section labeled "Forms for 1-N relations" for more details.
    – Stu Smith
    Commented Aug 14, 2019 at 17:25
  • I think we did not understand each other, it does not seem to work for the thing I need.
    – Julija M
    Commented Aug 15, 2019 at 9:19

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.