I've been working with qgis for a while but somehow I never fiured this out, so I thought it's time to ask.

I have 2 shapefiles.

  1. a polygon layer from nearby fields (SHAPE1 (the red outlines))
  2. a polygon layer, with different polygons than SHAPE1, that has soiltypes as an attribute (sand, clay etc.) (SOIL (the funky disco colors, each color represents a different soil type)

What I want to find out is what the main soiltype for each polygon in SHAPE1 is. (preferably by adding a field to SHAPE1 with the attribute from SOIL)

Is this possible?

enter image description here

2 Answers 2


With SQL:

  • import SHAPE1 and Soil layer to spatiaLite (plugin: QspatiaLite), then run a query and load as table in QGIS.

the SQL:

  SHAPE1.plgnID As ID, 
  Soils.soiltype As soiltype,

..assuming we have a field with polygon IDs plgnID in layer SHAPE1 and a field soiltype in layer Soils!

enter image description here

  • check result

enter image description here

  • join table to SHAPE1

enter image description here

ps: Of course you could do the intersection, aggregation and join in one go with SQL - but for SQL-illiterates like me, the above approach is much more transparent;)


You need to create a spatial join. The MMQGIS plugin does this quite easily - MMQGIS -> Combine -> Spatial Join. A tutorial is available here.

  • 2
    I think this is not what @Macgeizer wants - I guess by the 'main soiltype' the one with the largest area intersecting a polygon of SHAPE1 is meant. One QGIS-only approach would be: intersect the two layers and calculate the area of each intersection feature. Then use the "dissolve with stats" plugin to aggregate over unique indentifiers of polygons from SHAPE1 within the intersection layer and use MAX of area as statistic. Finally join the results to SHAPE1..
    – Kay
    Nov 26, 2014 at 12:58
  • After importing to spatiaLite with the QspatiaLite plugin, you could do all of this in one go: here's a post where a very similar problem is solved with SQL.. gis.stackexchange.com/questions/78977/…
    – Kay
    Nov 27, 2014 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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