2

I have often used the Zonal Statistics plugin to calculate the mean pixel value of a raster. However, this time I have an additional Boolean (pixels are equal either to 1 or to 0) raster, which is overlapping with the other. I would like to calculate some kind of "conditional mean" of the former raster, i.e. the mean for those pixels which in the latter raster are equal to 0 and to 1. Can anyone suggest an approach? Is maybe R more appropriate that the the GRASS-GIS environment for doing so?

1 Answer 1

2

In GRASS-GIS you can do it quite easily.

Assuming your binary raster with 1/0 value is named 'my_binary_raster', and the other you want to compute the mean value is named 'base_raster'. Don't forget to define your Computational region correctly !

# Compute basic statistics on the base_raster, for each zones of the binary
g.region raster=base_raster
r.univar map=base_raster zones=my_binary_raster

It will return mean and a lot of other statistics.

https://grass.osgeo.org/grass74/manuals/g.region.html https://grass.osgeo.org/grass75/manuals/r.univar.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.