I am trying to merge field areas from a polygon layer into a point layer
So the field area from this polygon onto the dot layer.
Where the Point layer, has an String attribute, and set to Multiline, so it would look like this:
I can generated the area measurement, using Field Calculator QGIS 2.14, Expression $area
(Though I understand there can be/is errors with this method)
Point Layer:
Polygon layer:
Join by field location
You can do a spatial join but that just adds another column with the attributes, but I need another step.
Join by field location I believe adds the area location from the polygon layer to the point layer. Go to Menu, Vector, Data Management Tools, Join Attributes by location
(Hopefully this will work when you have smaller polygons and points closer together as the distances between points/polygons is quite small)
I need to merge the columns generated as well. So the area column needs to become more like the Label column. (see picture)
I am looking to avoid manually copying and pasting the data from one column into another in the attribute table. In that case, it will be easier to measure each polygon individually using the identify tool, and then enter the label name and area one by one.
Try 3 – Pnz answer – Unsuccessful
Create 2 new layers
Names 2 – Point layer
Attribute: Label, String, multiline
Polygon 2 – polygon layer
Created area attribute on Polygon 2 using field calculator
Had both layers editable
Ran Vector -> Data Management Tools -> Join by Location
Created a new point layer but with 3 attribute columns:
Label, id, area
Test 2
Ran Vector -> Data Management Tools -> Intersect
This creates a new point layer with 3 attribute columns
Label, id, area
The issue is that the label needs to be as follows
I don't think "intersect" or "join by location" will join, and "wrap" in effect 2 lots of attribute column data.
I have had both layers editable, but since the Intersect and Join by location tool create new layers, I don't think the layers being editable is the issue.
Best Answer
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
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
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...
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.