9

This question already has an answer here:

I am looking for a possibility to make a one-to-many table-join in QGIS.

I have a shapefile with postal codes and would like to join them with survey results (more than one). In other words, there is a specific postal code (shapefile) on one side and there are many survey participants on the other side.

postal **code1** ----- survey participant **1**
postal **code1** ----- survey participant **2**
postal **code1** ----- survey participant **3**
postal **code2** ----- survey participant **1**
postal **code2** ----- survey participant **2**
and so on ...

If I do a normal join (right click on Layer --> Properties --> Join) , I just get the first entry of the table with the postal codes.

I found out a way to do it ArcGIS with the tool "Make Query Table", but I´m looking for a possibility to do it in QGIS.

marked as duplicate by underdark qgis May 20 '17 at 12:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Jul 26 '15 at 11:03
5

Depending on what exactly you want to do, you can use the relations functionality in QGIS.

See https://web.archive.org/web/20160313201132/http://blog.vitu.ch/10112013-1201/qgis-relations

This allows you show a table of related participants on the feature form of a zip code.

  • 2
    That a neat article thanks for sharing, can you expand this answer to include the parts that are relevant to this question? Sometimes links get broken and I think GIS.se tries to discourage link only answers. – SaultDon Jun 23 '16 at 16:53
  • 1
    The link to the blog post above is broken. Is there somewhere else that holds that post? – Johanna Mar 8 '17 at 4:23
0

You may use a processing scripts.

And here the one for an attributes cross-joining: https://github.com/kiselev-dv/QGIS-Processing/blob/master/scripts/spatial_cross_join_attributes.py

You may copy that script into {QGIS_HOME_DIR}/processing/scripts and use it via processing menu.

You have zip codes as an shape file, but I don't get in what form do you have survey data?

If they are points, import them as a new layer, and run spatial_cross_join_attributes script. It will asks you for two layers and name of results table. And in result table you'll get one row for each pair of zip and enclosed point.

zip1 point1
zip1 point2
zip2 point3
  • The survey data is a simple table (.csv) without any geometrys. – MTwain Jul 29 '15 at 13:03
  • I got a one zip code and many survey participants. – MTwain Jul 29 '15 at 13:11

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