4

I have an excel with 4 columns (Region; District; village; number of cases) Have a shapefile with dots for villages with many columns including (Region ; District ;Village)

I want to plot the cases of the excel (as dots on the villages) by joining the excel file and the shapefile.

The problem is that there are many villages (1000 in total) and many of them have the same name, but belong to different districts. The names of the districts are unique.

Therefore, I would need to join by 2 fields, (not only by village, but , by village and by district). I would need to join excel and shapefile by the fields "District" and " village" so the new column "cases" in created in the shapefile attributes table. I wonder HOW IS THAT DONE?? In QGIS I have learnt to join by 1 field (village), but if I add a second join (district) I lose many of my cases.

Is there a way QGIS can do that? Do I need to make some conditional or something?

  • The key here is to make two fields into one. Like lot and plan becomes lotplan (eg. Lot 10 on SP1234 -> 10/SP1234) in BOTH tables.. then join as normal. This is easy in Excel by adding a new header cell and use the function =A1 & "\" & B1 (or whatever you cells are) and then use field calc in QGIS. – Michael Stimson Jun 19 '15 at 23:21
  • That is a good idea. The problem is that you have to repeat the process for every single map you do since the selection at the excel (District and village) is done with drop-down menus. and I was rather looking for a long-term solution, to do many maps systematically (with diff data). Thank you very much – Elsa Jun 20 '15 at 8:57
  • Actually, it is not that difficult to do it for every single map. Thanks very much for the idea. – Elsa Jun 20 '15 at 9:24
  • @MichaelMiles-Stimson please post an answer so this thread can be marked as answered – underdark Jun 20 '15 at 9:56
6

The key here is to make two fields into one. Like lot and plan becomes lotplan (eg. Lot 10 on SP1234 -> 10/SP1234) in BOTH tables.. then join as normal. This is easy in Excel by adding a new header cell and use the function =A1 & "\" & B1 (or whatever you cells are) and then use field calc in QGIS. – Michael Miles-Stimson

  • 1
    Thanks for the credit Elsa.. perhaps you could extend this slightly with your own experience (and a few screen grabs) to take it from an answer to a good answer. – Michael Stimson Jun 21 '15 at 21:30
3

joinfield

So... this is how I have done it. For large number of entries, it works. I created drop-down menus in excel , then concatenate in excel: concatenate(a1;b1) then concatenate same fields in the shapefile using FIELD CALCULATOR : concat(field1,field2)

Then Join both and that.s it.

For few registries, I think you can enter data manually on a new column (shapefile). Many thanks for the idea, Elsa

  • Remember to accept your answer to close off your question (click the faded tick on the left hand side of your answer) :) – Joseph Jun 23 '15 at 10:39
0

Another way would be to add a new field with a unique identifier for each village, irrespective of name. EG "1" might be London (England) and "2" might be London (Canada).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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