[GRASSLIST:948] RE: Basic volume calculation question

Hamish hamish_nospam at yahoo.com
Thu Apr 27 20:50:33 EDT 2006


> Hm, I've been experimenting with r.volume's output on small datasets
> consisting of only a few pixels. It looks like r.volume calculates the
> average z-value of the raster first, then multiplies this by nsres and
> ewres to get the volume. Why doesn't it just multiply the z-value of
> each pixel by the pixel's area?

a) algebraically you get the same answer
b) by working on the mean instead of each cell, you save 2
multiplication calls per cell, for a 1000x1000 raster you have a million
cells, it adds up. It's faster for the module to do it at the end.
Whenever you can take a constant operation out of a loop the faster the
loop becomes.


I would really like to know why r.volume and r.univar give slightly
different means for the same data.


Hamish




More information about the grass-user mailing list