With some help managed to sort the issue.
You can merge columns using the field calculator and add /n to add a new line
Rough notes
Point layer - labels you want:
Name
area ha
Polygon layer: polygons + areas
- Set Project Projection to local map area, i.e. base units needs to be in metres ect.. so that the area calculation is more accurate.
2. Polygon layer, create the areas
Turn toggl editing on
Open attribute table
Select Field calculator
Create new field, give name: Area
Output Field type: Decimal number (real)
Output Field Length: 2, Precision 2
I think if you set the precision to 2 it will correctly round the area to the length of the precision
Expression: $area
There are errors this way of producing areas
You get the following in the attribute table
id ¦ area¦
0 ¦ 1.19 ¦
1 ¦ 3.74 ¦
2 ¦ 4.52 ¦
3 ¦ 2.81 ¦
ect...
Save the layer
2.b You can add the labels to the polygon layer which can be quicker if you have many to add.
3. Point layer
You need a point in the middle of each polygon. Take care with very small/close together polygons.
You can add the labels as you add the points or you can use Join by location function to add labels and areas from the polygon layer.
Run Vector -> Data Management Tools -> Join by Location
Input vector layer: Points layer
Intersect layer: Polygon layer
Output, press browse, go to where you want to save the shp file, give a file name like: Labels
Tick
Add result to canvas
Press OK
- Open the attribute table on the new layer: Labels, and enable toggle editing
Attribute table be like this:
id ¦ Name ¦ id ¦ area ¦
5 ¦ Label 1 ¦ 0 ¦ 1.19 ¦
6 ¦ Label 2 ¦ 1 ¦ 3.74 ¦
7 ¦ Label 3 ¦ 2 ¦ 4.52 ¦
8 ¦ Label 4 ¦ 3 ¦ 2.81 ¦
ect...
- You can now combine and "wrap" + new line the columns together using functions in the field calculator
Open Field Calculator
Tick Create a new field
Output Field Name: Labels
Output field type: Text (string)
Output field length: 80
Expression:
"Name" ||'/n' || "area" || ' ha'
Name = attribute field with all the labels in it
Area = attribute field with all the areas
(You can use another wrap symbol instead of /n)
Then press OK
This creates
Attribute table be like this:
id ¦ Name ¦ id2 ¦ area ¦ Labels ¦
5 ¦ Label 1 ¦ 0 ¦ 1.19 ¦ Label 1 ¦
¦ 1.19 ha ¦
6 ¦ Label 2 ¦ 1 ¦ 3.74 ¦ Label 2 ¦
¦ ¦ ¦ ¦ 3.74 ha ¦
7 ¦ Label 3 ¦ 2 ¦ 4.52 ¦ Label 3 ¦
¦ ¦ ¦ ¦ 4.52 ha ¦
8 ¦ Label 4 ¦ 3 ¦ 2.81 ¦ Label 4 ¦
¦ ¦ ¦ ¦ 2.81 ha ¦
ect...
(Can't seem to indent)
Press save as
Double click on the layer, or right click and go to properties, Labels
Select the drop down: show labels
Then select the new field called: Labels
Press Ok
The label + area should appear on the map
Then go to properties, Fields, select the id, Name, Id2 and area columns and delete these
Then save the layer
How to add labels to the polygon layer first
Create a new attribute, make that a string (text) and you can select each polygon in the attribute table, this makes the polygon go yellow (default colour) you then add the name to relevant column in the attribute table
You can export and possible reimport the data using MMQGIS
You could combine and adjust the attribute table in excel then join and reimport but field calculator is easier.
Best Answer
The problem with
NULL
values are related to missing geometry, here is the message: