# Calculate area covered by a particular raster layer within polygons in QGIS

I am trying to extract information on vegetation cover within a set radius of point locations (my sites). I have succeeded in creating a new vector layer of circles with a 5 km radius around my sites.

What I want to do is calculate the amount of vegetation cover within each of these circles (and therefore, within a 5 km radius of my sites), which I have as a raster layer. I would like to extract this either as a direct measurement of land cover (e.g. metres squared), or even just a percentage of the 5 km radius circle/polygon that is covered by the raster layer of vegetation (because I could then calculate the land cover from that).

I am aware that the LeCos plugin can somehow do this, but I have not succeeded in installing this (subject of another question I have posted) and was hoping there might be another way. I would be open to trying this in R if someone can point me in the right direction ( I am a user of R for statistical analysis but haven't yet tried it for spatial analysis).

• Can you give a little more information on the raster? From the graphic, I am assuming that the raster has different values for different land classes (ie: forest, water, grass, etc.) Commented Dec 12, 2013 at 0:04
• Yes, the raster has a value for each land cover type (e.g. 1= rain forests, up to 29- it is the NVIS if you are Australian). My thoughts were to separate out the land cover types into individual rasters first, and then evaluate each land cover type separately (I have another question on this forum in which I'm trying to figure out how to do that). Not sure if that is just complicating things though.
– Pop
Commented Dec 12, 2013 at 2:27
• If you use R, read the following gis.stackexchange.com/questions/61243/clipping-a-raster-in-r. And note, that Florian's answer is faster (it pays off to crop the raster first and then mask it) Commented Jan 23, 2014 at 6:48

I suggest to use grass for doing this. What you need is v.rast.stats (you can find it in the grass plugin for Qgis). This tool uploads the value of the raster to your vector layer. Just pay attention to the resolution of your raster layer (bigger are pixel more difficult it is to approximate your circle so the area that you analyze it's not exactly a a 5 km radius circle).

Following on from Pop's comments above. I used OS mapping and selected houses on it before.

The polygons i extracted are a little ragged. OS Street View images are (single-band) indexed TIFFs. Using the raster value tool told me that the pixel value for buildings was 204 and I used this value in the Raster Calculator to make a new TIFF in which all of the pixels in the image having a value of 204 were converted to ones and all of the pixels in the image having a value not equal to 204 were converted to zeros. The expression to do this is 'filename@1 = 204' (without the quotes).

It was then simply a matter of polygonising the new TIF: Raster -> Conversion -> Polygonize (Raster to vector).

Sorry, then you would need to only select the polygons within the buffers.

Ger

• Thanks for your comments Gerald- so it sounds like an option would be to separate out each land cover type by using the raster calculator to extract each pixel value; then polygonize these layers; then clip them with my buffers. I wonder then how I would extract the amount of cover of the land cover types within each of my buffers? I have thousands of sites so couldn't do this one by one.
– Pop
Commented Dec 12, 2013 at 23:41
• I would use the Spatial Query Pluggin. in this i would look for features in layer Vegitation which are whithin the buffer layer.
– Ger
Commented Dec 13, 2013 at 14:00