GRASS logo


v.rast.bufferstats - Calculates statistics of raster map(s) for buffers around vector geometries.


vector, raster, buffer, statistics


v.rast.bufferstats --help
v.rast.bufferstats [-tpur] input=name raster=name[,name,...] buffers=integer[,integer,...] type=string[,string,...] [layer=string] column_prefix=string[,string,...] [methods=string[,string,...]] [percentile=integer] [output=name] [separator=character] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Tabulate area within buffers for categories in raster map(s)
Used with -t flag will return percentage of area for categories
Update columns if they already exist
Remove columns without data
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name [required]
Name of input vector map
Vector map containing geometries to compute buffer statistics for
raster=name[,name,...] [required]
Raster map(s) to calculate statistics from
buffers=integer[,integer,...] [required]
Buffer distance(s) in map units
type=string[,string,...] [required]
Vector type to work on
Options: points, lines, areas
Default: points,lines,areas
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
column_prefix=string[,string,...] [required]
Column prefix for new attribute columns
The methods to use
Options: number, number_null, minimum, maximum, range, sum, average, average_abs, stddev, variance, coeff_var, first_quartile, median, third_quartile
Default: number,number_null,minimum,maximum,range,sum,average,average_abs,stddev,variance,coeff_var,first_quartile,median,third_quartile
Percentile to calculate
Options: 0-100
Name for output file (if "-" output to stdout)
Field separator
Field separator in output file
Default: |

Table of contents


The purpose of the v.rast.bufferstats module is to provide local environmental context to a series of input geometries. It computes statistics from multiple input raster maps within multiple buffers around selected geometries in the input vector map.

Available statistics are either

  1. statistics provided by r.univar or
  2. if the t-flag is checked - area of, number of and/or the most frequent (mode) raster categories within the buffers using r.stats.

If output option is specified, results are written to file or stdout in stead of attribute table of the input map. File output is produced with the following column order:
cat | prefix | buffer| statistic/measure | value
separated by the user defined separator (default is |).


The module temporarily modifies the computational region. The region is set to the extent of the respecive buffers, while the alignement of the current region is kept.


g.region -p raster=elevation,geology_30m
v.clip --o -r input=bridges output=bridges_wake

# Tabulate area of land cover map
g.region -p raster=elevation,geology_30m align=geology_30m
v.rast.bufferstats -t input=bridges_wake raster=geology_30m buffers=100,250,500 column_prefix=geology

# Compute terrain statistics
g.region -p raster=elevation,geology_30m align=elevation
r.slope.aspect elevation=elevation slope=slope aspect=aspect
v.rast.bufferstats input= raster=altitude,slope,aspect buffers=100,250,500 column_prefix=altitude,slope,aspect methods=minimum,maximum,average,stddev percentile=5,95


In order to avoid topological issues with overlapping buffers, the module loops over the input geometries. However, this comes at costs with regards to performance. For a larger number of geometries in the vector map, it can be therefore more appropriate to compute neighborhood statistics with r.neighbors and to extract (v.what.rast, r.what) or aggregate (v.rast.stats) from those maps with neighborhood statistics.

The module is affected by the following underlying library issue: Currently, the module uses GRASS native buffering through pygrass which should be replaced by buffering using GEOS:


r.univar r.stats v.rast.stats


Stefan Blumentrath, Norwegian Institute for Nature Research, Oslo, Norway


Available at: v.rast.bufferstats source code (history)

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

© 2003-2020 GRASS Development Team, GRASS GIS 7.8.3dev Reference Manual