1

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.

enter image description here

Where the Point layer, has an String attribute, and set to Multiline, so it would look like this:

enter image description here

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:

enter image description here

Polygon layer:

enter image description here

enter image description here

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)

enter image description here

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.

enter image description here

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
enter image description here

Created a new point layer but with 3 attribute columns: Label, id, area
enter image description here

Test 2

Ran Vector -> Data Management Tools -> Intersect enter image description here

This creates a new point layer with 3 attribute columns
Label, id, area enter image description here

The issue is that the label needs to be as follows

enter image description here

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.

  • I think you need to use MMQGIS to export and import csv files. I think you can wrap the attributes using excel and probably excel macros. I will do some research and post an answer if I get one. – maskin Nov 15 '17 at 14:18
1

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

  1. 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

  1. 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...

  1. 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.

0

Join Attributes by location should solve this.

Maybe you should save the edited layers first (Toogle off Editing).

Click to the pencil icon.


Try to intersect the two layers (that stores attributes from both layers):

Vector -> Geoprocessing -> Intersection

Input: Points

Intersect: Polygons

  • thanks, I am aware of the function, I have tried to clarify I need another step after this. – maskin Oct 25 '17 at 13:51
  • The problem could be that, you haven't saved the layers by finish editing. – pnz Oct 25 '17 at 15:58
  • I don't believe saving the layers is the issue. The Join Attributes by location creates a new output shape file. I need to merge the 2 columns after the join attributes by location has been run. – maskin Oct 30 '17 at 9:44
  • I edited my answer, please try it, if it is possible. – pnz Oct 31 '17 at 17:38
  • thanks but I don't think your answer helps with the "wrapping" as discussed. I have added some pictures, I think one needs to use excel to adjust the columns then reimport – maskin Nov 15 '17 at 14:19

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.