How to calculate an area-weighted average in GRASS
# set the computational region to the value raster
g.region rast=val_rast -ap
# convert the value raster to area vector
r.to.vect val_rast out=val_vect type=area
# overlay the value vector OR the area vector
v.overlay ainput=val_vect binput=area_vect oper=or output=val_area_vect
# calculate the areas of the value-OR-area vector polygons
v.to.db val_area_vect op=area col=area_m2
# add a new column for the area-weighted average
v.db.addcolumn area_vect col="avg_val double"
# populate the new column with the area-weighted average
v.db.update area_vect col=avg_val \
qcol="(select sum(a_value*area_m2)/sum(area_m2) from val_area_vect \
where val_area_vect.b_cat=area_vect.cat group by b_cat)"