You could run "Raster pixels to polygons", to convert your raster to a vector layer:
Make sure your Buildings have a unique id, then run "Intersection" with your Buildings:
So your attribute table contains the slope value in degrees and the building id. Now add a new field, counting the cells each building contains count("buildingid","buildingid")
:
And add a new field counting the cells lower than 3 degrees count("buildingid","buildingid","value"<3)
:
You can now calculate the percentage of each building, where the slope is lower than 3 degrees and use this as indicator.
Alternative:
Add a new field to your intersection layer, containing an inidcator wheter the value is smaller than 3 or not if("value"<3,1,0)
:
Now dissolve the layer by this new field as well as the buildingid:
Now run "Multipart to singlepart" to get individual areas. You can delete the field "value" now, to not get confused, it is no longer valid.
You can now either calculate the areas, the area percentage, count the number of "isolated" areas for each building, do a neighbour analysis, or whatever suits your usecase the best.
Or create an index, taking some things into account, like e.g.:
(
-- percentage of areas smaller 3 per building
sum($area,"buildingid","smaller3"=1) * 100 / sum($area,"buildingid")
*
-- number of areas smaller 3
count("buildingid","buildingid","smaller3"=1)
)
-
(
-- percentage of areas greater 3 per building
sum($area,"buildingid","smaller3"=0) * 100 / sum($area,"buildingid")
*
-- number of areas greater 3
count("buildingid","buildingid","smaller3"=0)
)
Which would for example turn back something like this:
Note that this index is just an idea, its up to you how you would like to determine which areas are good for you and which are not!