2

I map species records using QGIS 2.14.2. Many of the records have been submitted with exactly the same grid reference for different species. This can up to twenty records (labels). But QGIS will only show one of the records (labels) for that grid reference. I have checked "Show all labels". How do I get QGIS to show all the labels (records) for the one grid reference? Ideally this would be in a column or columns?

1

right click on the layer -> go to properties->go to labels -> tick 'label this layer with'-> click on the epsilon sign (expression dialog) and based on the example below type in your expression:

 'data1: '||$rownum || ' data2: '|| $id ||'\n' ||'data2: '||$currentfeature || ' data3: '|| $scale

where the $text is the name of a column enter image description here

hope it helps.

Here is my update. Maybe you need to add some additional column or changes to your existing table like label_id (autoincrement) ordered by x or y coordinates. My expression is based on the number of 20 of maximum overlapping points, but in the condition you can add more. Please see my example: I have created a point layer with three attributes: is, species, info1.

Add label: right click on the layer -> go to properties->go to labels -> tick 'label this layer with'-> click on the epsilon sign (expression dialog) and based on the example below type in your expression: 'data1: ' || species || ' data2: '|| info1 || ' data3: '|| id

With this step you will see all the labels with their attributes, however if you have overlapping points you cannot see each layer especially if you have 20 overlapping. Here is my sample dataset (all the points are in the same position):

enter image description here

And here is the trick: right click on the layer -> go to properties->go to labels -> go to placement -> use offset from point -> change offset unit to millimeter -> and add an offset expression (highlighted on the picture below in the OFFSET X,Y line)-> clic on the expression button and edit. enter image description here

Here is my sample expression, the rule is based on the species id:

CASE 
    WHEN right(species,2)= '01' THEN 
   '0,-2'
    WHEN right(species,2)= '02' THEN 
   '0,4'
    WHEN right(species,2)= '03' THEN 
   '0,-6'
    WHEN right(species,2)= '04' THEN 
   '0,8'
    WHEN right(species,2)= '05' THEN 
   '0,-10'
    WHEN right(species,2)= '06' THEN 
   '0,12'
    WHEN right(species,2)= '07' THEN 
   '0,-14'
    WHEN right(species,2)= '08' THEN 
   '0,16'
    WHEN right(species,2)= '09' THEN 
   '0,-18'
    WHEN right(species,2)= '10' THEN 
   '0,20'
    WHEN right(species,2)= '11' THEN 
   '0,-22'
    WHEN right(species,2)= '12' THEN 
   '0,24'
    WHEN right(species,2)= '13' THEN 
   '0,-26'
    WHEN right(species,2)= '14' THEN 
   '0,28'
    WHEN right(species,2)= '15' THEN 
   '0,-30'
    WHEN right(species,2)= '16' THEN 
   '0,32'
    WHEN right(species,2)= '17' THEN 
   '0,-34'
    WHEN right(species,2)= '18' THEN 
   '0,36'
    WHEN right(species,2)= '19' THEN 
   '0,-38'
    WHEN right(species,2)= '20' THEN 
   '0,40'

 ELSE 
    '0,-42'
END

It means you need to use the ending of your ID's (right formula) and each cases you need to set different offset. If you use ID's ending from 0-9 it my can happen you will have overlapping labels (if you have maximum 20 overlapping points), this is why it's necessary to add additional label_id column with cyclic label_id numbers. And the cyclic range should be the maximum number of the overlapping points.

End the result is:

enter image description here

  • Thank you Thomas. I tried your good idea to use an use expression. I the expression"Species Latin Name" || '\n' . This should have put each label on a new line like this: – Tony Rowlands May 8 '16 at 14:48
  • Thank you Thomas. I tried your good idea. I used the Expression "Species Latin Name" || '\n' . I also selected "Offset from Point" placement. This should have put each label on a new line so that I had a vertical list of labels. But it didn't work. The best I could do was get 8 labels around the point by selecting "Around Point" placement. At least I learned how to used Expressions! But I am still doing something wrong and I can't figure out why I can't get it to work. – Tony Rowlands May 8 '16 at 14:54
  • @TonyRowlands if you send me the column names of your data table, i'll create for you that expression (or part of it as example) – Tamas Kosa May 9 '16 at 6:09
  • Thank you Tamas. I am grateful. This is a copy of the columns and first row. I am trying to get the Species Latin Names names (labels) Bombus terrestis, Bombus humilis etc one above the other close to the location marker. There can be up to 20 or more names collected at one location. Column names: OBJECTID Date input Day Month Year Site name OS Grid Ref Eastings Northings SPTA Zone Order Species Latin Name Species common name Species count Recorder Data Date GI Captured Row one: 1 6/24/2011 28 May 2011 SPTA (W) ST978522 397800 152200 Hymenoptera Bombus humilis 1 – Tony Rowlands May 9 '16 at 13:24
  • It might be clearer if I specify the column numbers for the Column Names: 1. OBJECTID 2. Date input 3. Day 4. Month 5. Year 6. Site name7. OS Grid Ref 8. Eastings 9. Northings 10. SPTA Zone 11. Order 12. Species Latin Name 13. Species common name 14. Species count 15. Recorder 16. Data 17. Date GI Captured – Tony Rowlands May 9 '16 at 13:27

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.