Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a csv table, with data in this format: "name","country". Country code is in the same format as the world map SHP file attribute table (both are in the ISO standard). I learned how to join the tables together, but I want to colorize countries based on how many people are from each country.

Example:

  • "john","LVA"
  • "peter","OMN"
  • "martin","PRI"
  • "janis","LVA"

In this case Latvia should be darker than the two other countries (because two people are from LVA). I know how to colorize things based on a number that's bigger than other numbers, but how to achieve it without the numbers in the table? I only have raw list of names. Is this possible with Qgis only?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You should not join tables together: it will cause multiplication of the same geometries (countries). Add a column to the .shp with countries and store number of people there. (But it seems that you should count numbers of people in other software - I don't see 'count' option in field calculator.) Then colourise your map using this field.

If the table with names and nationalities is constantly updated, then you should think about using spatial database for dynamical update of your map. You may store there table with countries and table with names and use view (that will count people and join this number with countries) to produce your map layer.

share|improve this answer
    
Thank you, and also Stev_k for replies! I will use an external program to summarize the data, and for future, I will look at possibility of using a database. Thanks! –  normis Apr 26 '12 at 10:28
    
Can you clarify how to add data in the new column of the attribute table (without typing by hand) without using the Join feature? –  normis Apr 26 '12 at 11:27
2  
normis, once you have summarized your cvs data and imported into QGIS, you will want to use the join table layer function of your shp layer (as Stev_k noted). SS_Rebelious missed that your secondary set of data were not spatial. There is a good write-up about this here. The QGIS join is one-to-one, so your people-per-country count field will extend the countries of your world map shapefile (given that the country codes match). Save to a new shape file to write the new data. Consider moving to a database, as noted. –  dakcarto Apr 26 '12 at 11:43
    
Thanks! This helps –  normis Apr 26 '12 at 12:48

It might be, but I wouldn't have thought it would be very easy if it is possible. See these questions here and here. These questions are more about one to many relationships, but what you want seems more akin to the Mapinfo Table Update command which sums datafields for you based on a join to another table.

I think @SS_Rebelious is right, you probably need to do this in an external program. Take that advice re using a database if this is a large dataset or it changes regularly. If it's a one off, I would suggest summarising your csv file with a count of countries (perhaps a Pivot Table) and importing the new table into QGIS. You should then be able to join the table to your countries shapefile, using the join table tab in the countries properties.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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