How to get mean geographic direction of a polygon in QGIS?

I have a raster height model and would like to calculate the horizontal geographic direction (north, east, etc. - orientation) of each cell, then calculate then the mean value of all these cells in one region (polygon). This is to get information about to what direction a vineyard is exposed to. How do I do this?

The 'direction' you are referring to is known as the aspect of a slope. To calculate this for a raster DEM in QGIS you need to use the Raster > Analysis > DEM (Terrain models) tool which has a mode for aspect. There's a tutorial for working with terrain analysis in the QGIS Training Manual - lesson 8.3.

Once you've generated an aspect raster from your DEM, you can use the Raster Calculator and Zonal Statistics plugin to get the mean aspect value from your regions (zones). As whuber's comment points out this calculation is more complex than it initially sounds, and you can refer to his answer at Sum raster data visible from given point, by proportion of view for full details.

The values generated by the aspect analysis are angular (I believe clockwise from north, but you should confirm that). So if you want a N/E/S/W direction to that, you'll have to determine how fine you want to go (northwest or north-northwest) and then assign it based on the angular value.

• Zonal stats, applied directly to aspects, will likely produce some wildly incorrect values. Proper procedures for averaging angular values have to be followed. The correct understanding of mean aspect in this application probably should take into account slope, too, so what is likely needed is the mean normal vector to the slope. Details can be found at gis.stackexchange.com/questions/53664/… and gis.stackexchange.com/questions/7496/… May 16, 2015 at 20:38
• @whuber You're right, I didn't think that one all the way through. Not only was I making some assumptions based on what the zones were and how small I thought they'd be (which is largely irrelevant), I didn't (don't) fully understand all the math issues and apparently forgot how complicated the angular value thing was; because your comment is ringing bells now. May 16, 2015 at 20:59
• @whuber I have a Aspect raster with polygons overlaid on it. I am looking for mean aspect (slope directions) of each polygon by applying Zonal Statistics in ArcGIS. Do I need to consider slope in this case as well? Looking for guidance.
– Dave
Oct 3, 2021 at 15:51
• @Rex It comes down to how you intend to interpret "mean aspect." Regardless, you do have to use methods of analyzing circular data. To see why, consider a polygon pointing due north, give or take a few degrees. Some of the aspects will be 0, 1, 2 degrees and others will be 359, 358, 357 degrees. The average will likely be close to 180 degrees, which is exactly the opposite of the average direction. You must also treat the special aspect value of -1 properly (this represents an unknown aspect when the slope is zero). Oct 3, 2021 at 17:42
• @whuber I am obliged for clarity and enlightenment. Kind regards.
– Dave
Oct 4, 2021 at 12:38