1

I have two vector layers: 1) with polygons representing landcover types and 2) a grid, overlapped with the first one.

I want to obtain, for each square within the grid, the number of land cover types. For example: enter image description here

In the red square it would have 2 landcover types (2 and 7), and the left square to that one only 1 land cover type (2).

How do I obtain this values, using QGIS?

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Jan 31 '17 at 17:25
1

If you want to count the number of polygons within your grid, you may use the Join attributes by location tool from the Processing Toolbox.

For your specific case, these parameters should work:

enter image description here

The output of the tool will be a grid layer which stores the number of the intersected polygons in a new field, called "count".

3

Add a virtual layer (layer > add layer > add/edit virtual layer)

Import both grid- and landcoverlayer

In the query-window you can add following code. In the code you will have to change grid, landcover and type to what your layers and attributes are named of.

select grid.*, group_concat(landcover.type) as types from grid, landcover where st_intersects(grid.geometry, landcover.geometry)

Now you should get a new layer with a grid extended by an attribute called 'types'

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.