(1) I have a vector grid layer.

(2) I have a multipolygon layer. Each polygon has a specific type (in this case a vegatation type)

Now I want to get as an output the grid layer where each cell contains the type whose polygon (out of the vegetation - multipolygon layer) occupies the largest area.

Following figure shows the grid layer overlaping the multipolygon layer: Multiploygon layer overlaping by grid layer

  • Sorry to ask but ... do you mean you want to calculate the main vegetation type per grid cell ? Your question's title is clear ... but not the rest imho ...
    – Snaileater
    Aug 20, 2019 at 14:52
  • Yes, I want to get the main vegetation type per grid cell.
    – obrob
    Aug 20, 2019 at 18:02

1 Answer 1


Use QGIS DB Manager : Database / Database Manager / Database Manager then Virtual Layers / Qgis Layers.

Try a query like this one :

select grid.id,max(st_area(st_intersection(grid.geometry,vege.geometry))),vege.type
from vege, grid
where st_intersects(vege.geometry, grid.geometry)
group by grid.id

That should do the job ...

Adapt the query to your data structure if needed (columns namings) ...


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.