# Calculating green roof area in QGIS

I am trying to detect green roofs in a city and would like to compute the total area of green roofs (also on a per roof basis). I used a shapefile containing all roofs and used that to extract the roofs from an orthophoto and calculated NDVI through the raster calculator. Now I would like to compute the area of the green roofs. I'm hoping to get some kind of attribute table that shows me if a given building has a green roof and much m².

I tried using reclassify by table to create two classes (no vegetation & vegetation) and polygonized the output which sometimes resulted in hundreds of polygons within the boundaries of a single building.

I'm unsure about how to proceed or if I am even on the right track.

Please keep in mind that I am using QGIS.

• Look up 'zonal statistics' QGIS you have a polygon (roof) and you want the values from the raster pixels. This way it can calculate the mean values of the pixels. Then pull out the green roofs with a select by attributes. Not sure how your raster is classified. Can you give an example?
– Mapperz
Commented Jul 20, 2020 at 16:25
• Thanks, but in some cases the green area makes up just half of the roof or the roof is covered with lots of vents etc. which would skew the mean value of the pixels. I would rather want to only include pixels above a certain threshold. Classification was basically picking a pixel value as a threshold, meaning everything below that value = no vegetation and everything above = vegetation. Commented Jul 23, 2020 at 16:24

Maybe you already solved the problem and without image I don't know how the data exactly look like but this could work if you have the SHP with roofs.

1. upload/create raster with NDVI and vector layer with roofs into QGIS
2. use Zonal Statistics - statistics to calculate: Mean
3. you get new column in your vector layer with mean value of NDVI - find a threshold for which there is a vegetation (typically it is around 0.35 but you should find your own value Indentify Feature tool)
4. now you can use Field Calculator (you will find it in Attribute Table when you Enable Editing on the top toolbar) and write "if" condition (here is how to do it) You will create new field inside table which contains only TRUE-FALSE information.
5. you know exactly which roof polygons are with green roof, you can separate them (Select by Attribute) and calculate area only for these polygons (again Field Calculator -> Geometry -> Area)

If these "hundreds of polygons within the boundaries of a single building" retain the ID of the original building polygon, then you can sum these areas grouped by building ID (either via SQL in QGIS DBManager or just by exporting it to a CSV table and doing it in a spreadsheet).

As for the area of the original building roof, you can add that to your shapefile's attribute table with something like this.

If your original buildings shapefile doesn't have an unique ID, you can create one.

• The original buildings shapefile does have unique IDs but the "hundreds of polygons within the boundaries of a single building" have new IDs Commented Jul 23, 2020 at 11:34