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
@Dano rightly raises some issues that are best addressed in a full reply.
One difficulty, already noted by @Celenius, is that a join between B and A (in either direction) duplicates all the fields; it can be onerous to correct this. I have suggested in comments that the obvious easy way (export to a spreadsheet) raises questions of data integrity. Another difficulty, already addressed by Celenius' proposal, concerns solving this problem when no combination of attributes can serve as a key for both A and B, because that precludes a database join. The spatial join gets around that problem.
What, then, is a good solution? One approach uses A to identify the corresponding records of B containing the desired data. Depending on assumptions about the configurations of the polygons--whether they overlap, whether some can contain others, etc--this can be carried out in various ways: using one layer to select objects in the other, or via joins. The point here is that all we want to do at this stage is select the subset of B corresponding to A.
Having achieved that selection, export the selection and let it replace A. Done.
This solution assumes that all fields in B are intended to replace their counterparts in A. If not, then it really is necessary to perform a 1-1 join of B (source) to A (destination). The join based on identifiers is best, but making a join on polygon identity (Celenius) works fine if ids are not available and there's no chance corresponding polygon shapes in A and B might differ, however slightly. (This is a subtle point, and the potential cause of insidious errors, because previous edits in B to polygons that don't correspond to A could still invisibly modify the other polygons in B if the GIS is "snapping" or "maintaining topology" or otherwise automatically making global changes during local edits.)
At this juncture, there are two copies of every field: if [Foo] is a common field to A and B, then the join contains A.[Foo] and B.[Foo]. Using a field calculation, copy B.[Foo] into A.[Foo]. Repeat for all needed fields. After this is done, remove the join.
Although this procedure can be a little onerous when many fields are involved, its merits include
Some of the guiding principles involved in this suggestion are
One might object that in many cases there are faster and easier ways to reach the same result. Yes, there can be, and they can be effective and usually they work when performed with care. But solutions that risk the data are difficult to recommend and defend as general-purpose answers. They are best employed in one-off situations with small datasets where corruption in the data should rapidly become obvious and the consequences of any such mistakes are immaterial.