howtos:how_to_calculate_an_area-weighted_average_in_grass
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| howtos:how_to_calculate_an_area-weighted_average_in_grass [2026-10-23 01:32 am] – hcho | howtos:how_to_calculate_an_area-weighted_average_in_grass [2026-10-23 01:38 am] (current) – hcho | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| r.to.vect rast_val out=vect_val type=area | r.to.vect rast_val out=vect_val type=area | ||
| - | # calculate the cell areas of the area vector | + | # calculate the areas of the area vector |
| v.to.db vect_val op=area col=area_m2 | v.to.db vect_val op=area col=area_m2 | ||
| Line 14: | Line 14: | ||
| v.overlay ainput=vect_val binput=vect_area oper=or output=vect_val_area | v.overlay ainput=vect_val binput=vect_area oper=or output=vect_val_area | ||
| - | # add and populate | + | # add a new column for the area-weighted average |
| + | v.db.addcolumn vect_area col=" | ||
| + | |||
| + | # populate the new column with the area-weighted average | ||
| v.db.update vect_area col=avg_val \ | v.db.update vect_area col=avg_val \ | ||
| qcol=" | qcol=" | ||
| where vect_val_area.b_cat=vect_area.cat group by b_cat)" | where vect_val_area.b_cat=vect_area.cat group by b_cat)" | ||
| </ | </ | ||
howtos/how_to_calculate_an_area-weighted_average_in_grass.txt · Last modified: by hcho