The image below is of vineyard blocks on different soil types (four larger polygons - all different layers).

Enter image description here

I would like to create a new attribute in the vineyard layer called soil type and fill it with the value from the four different soil type layer's attribute called description.

In the case where the soil types overlap the vineyard blocks, the attribute soil type should be where more than 50% of the block lies within the soil type. I have looked, but cannot find a answer.

I have tried geomwithin('Alluvial', 'Description') - a function I get in the field calculator after I installed the plugin refFunctions. However, this only works, of course, if the vineyard polygon is completely within the soil type. I have played around with Union, but I cannot see how that will help me.

Can someone please help me? I would prefer a expression, as I have no knowledge of scripting.


I would suggest using the join attribute by location

Here is a few images of the dialog you would encounter.

enter image description here

enter image description here

Also, you could use the Spatial Query plugin which is now a core plugin in QGIS and the NNJoin plugin as ways to tackle your issue.

Spatial Query Plugin

The spatialquery Spatial Query Plugin allows you to make a spatial query (i.e., select features) in a target layer with reference to another layer. The functionality is based on the GEOS library and depends on the selected source feature layer.

Possible operators are:

Is disjoint

NNjoin Plugin

The NNPlugin joins two vector layers (the input and the join layer) based on nearest neighbour relationships. All geometry type combinations are supported. A feature from the input layer is joined to the nearest feature in the join layer. The result of the join is a new vector layer with the same geometry type and coordinate reference system as the input layer. Joining layers with different Coordinate Reference Systems (CRS) is supported, as long as the join layer coordinate system is a projected CRS. The join and distance calculations is performed using the join layer CRS. Self joins are supported. For self joins, each feature in the layer is joined to its nearest neighbour within the layer. A spatial index (QgsSpatialIndex) on the join layer is used to speed up the join for layers with non-multi-geometry types.

| improve this answer | |
  • Thank you whyzar. I have tried your suggestions with no avail. I need the attribute added to the layer if the overlap is 50% or more. In all three of your suggestions I cannot see how to do that. One would think this would be fairly easy in a GIS? – Gideon Sep 29 '17 at 9:42
  • I think the following is my answer gis.stackexchange.com/a/176729/12009. However when I paste the code into the Python console I get the following error : floodName = ‘Wingerdblokke2017’ File "<input>", line 1 floodName = âWingerdblokke2017â ^ SyntaxError: invalid syntax. Any help would be much appreciated. I have no knowledge of Python. Regards – Gideon Oct 2 '17 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.