howtos:how_to_calculate_an_area-weighted_average_in_grass
This is an old revision of the document!
How to calculate an area-weighted average in GRASS
# set the computational region to the value raster g.region rast=rast_val -ap # convert the value raster to area vector r.to.vect rast_val out=vect_val type=area # calculate the cell areas of the area vector v.to.db vect_val op=area col=area_m2 # overlay the value vector OR the area vector v.overlay ainput=vect_val binput=vect_area oper=or output=vect_val_area # add and populate a new column with the area-weighted average v.db.update vect_area col=avg_val \ qcol="(select sum(a_value*a_area_m2)/sum(a_area_m2) from vect_val_area \ where vect_val_area.b_cat=vect_area.cat group by b_cat)"
howtos/how_to_calculate_an_area-weighted_average_in_grass.1792719134.txt.gz · Last modified: by hcho