I have data from a national census with population for each neighbourhood, grouped by municipality and town, in the country. I want to select the most populated neighbourhood of each town (there's a couple of thousands of them).

Can this be done in QGIS?

enter image description here

  • 3
    I'm not sure I understand your select neighborhood sentence/question, can you expand more on this and provide a visual example? – artwork21 Feb 10 '16 at 4:45
  • 1
    What exactly do you mean by "every neighborhood with more inhabitants in each town"? Is there a number that you have in mind? what criteria are you using? – Hasan Mustafa Feb 10 '16 at 4:47
  • 2
    I think the question is "how to select the most populated neighbourhood of each town". I edited the title in this direction. – jeremy g Feb 10 '16 at 14:28
  • 1
    Your best bet may be to install PostgreSQL with PostGIS plugin, and use the PostgreSQL MAX Function: postgresqltutorial.com/postgresql-max-function – PDX Feb 10 '16 at 14:41
  • Like jeremy g put it: how to select the most populated neighbourhood of each town. In the picture I added, there's an example of a town, divided by neighbourhoods, which are painted according to population density. – sig_renato Feb 10 '16 at 17:24

You could use the Group Stats plugin, which works like an Excel pivot table. Set your town field as columns and the neighborhood field as rows, then calculate the Max of the population field.


Install the dissolve with stats plugin. Dissolve by the towns attribute, adding a stat for the max neighbourhood population. Join the data table created to your original one using the towns attribute and then query the neighbourhoods for ones where the population = the max stat in the joined table. A bit messy but should work.

  • Somehow, that plugin is not available for QGIS Wien (Mac). So I can't try it out. I sorted it using SQLite, but I'm still looking for a solution using QGIS. – sig_renato Feb 12 '16 at 1:43
  • 1
    I am on 2.12.1 (Mac) using KyngChaos version – Sethinacan Feb 15 '16 at 7:54
  • I used that one for a while, but I had problems styling layers. I couldn't change the line type, could not choose its colour, could not set layers' colour using functions and so on… Don't you have these issues on 2.12.1? – sig_renato Feb 15 '16 at 14:47

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.