Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.

GRASS logo

NAME

v.rast.stats - Calculates univariate statistics from a raster map based on a vector map and uploads statistics to new attribute columns.

KEYWORDS

vector, statistics, raster, univariate statistics, zonal statistics, sampling, querying

SYNOPSIS

v.rast.stats
v.rast.stats --help
v.rast.stats [-cd] map=name [layer=string] [where=sql_query] raster=name[,name,...] column_prefix=string[,string,...] [method=string[,string,...]] [percentile=integer] [--help] [--verbose] [--quiet] [--ui]

Flags:

-c
Continue if upload column(s) already exist
-d
Create densified lines (default: thin lines)
All cells touched by the line will be set, not only those on the render path
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

map=name [required]
Name of vector map
Or data source for direct OGR access
layer=string
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
where=sql_query
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
raster=name[,name,...] [required]
Name of input raster map to calculate statistics from
column_prefix=string[,string,...] [required]
Column prefix for new attribute columns
method=string[,string,...]
The methods to use
Options: number, null_cells, minimum, maximum, range, average, stddev, variance, coeff_var, sum, first_quartile, median, third_quartile, percentile
Default: number,null_cells,minimum,maximum,range,average,stddev,variance,coeff_var,sum,first_quartile,median,third_quartile,percentile
percentile=integer
Percentile to calculate
Options: 0-100
Default: 90

Table of contents

DESCRIPTION

v.rast.stats calculates basic univariate statistics from a raster map only for the parts covered by the specified vector map. The vector map will be rasterized according to the raster map resolution. Then univariate statistics are calculated per vector category (cat) from the raster map and the results uploaded to the vector map attribute table. A new column is generated in the attribute table for each statistic requested in method (if not already present).

The univariate statistics include the number of raster cells counted, the number of raster NULL cells counted, minimum and maximum cell values, range, average, standard deviation, variance, coefficient of variation, sum, first quartile, median, third quartile, and percentile.

NOTES

v.rast.stats is only meaningful for lines or polygons.

The module may take a long time to run if the raster region contains a large number of cells. In this case the --verbose flag may be used to track progress.

The script stops if a (prefixed) upload column is already present in the vector map attribute table, unless otherwise instructed with the -c continue flag. The column prefix will be separated from the statistic name with an underscore. For example with a prefix of "elev" the sum column will be named elev_sum.

If a DBF database is being used, note that column names are restricted by the DBF specification to 10 characters. Therefore it is advised to be economical in the use of the column prefix when using DBF as any additional characters will be chopped off.

If a MASK is present, it will be restored after the script finished. The script changes temporarily to the resolution of the given raster map.

Large amounts of system memory can be used when extended statistics (first_quartile,median,third_quartile,percentile ) are being requested with a very large region setting. If the region is too large the module should display memory allocation errors. Basic statistics can be calculated using any size input region.

EXAMPLES

Example to upload DEM statistics to ZIP codes vector map (North Carolina sample dataset):
g.copy vect=zipcodes_wake,myzipcodes_wake
# set computational region to DEM:
g.region raster=elevation -p
# calculate selected DEM statistics, upload to vector map table:
v.rast.stats myzipcodes_wake raster=elevation \
  column_prefix=elev method=minimum,maximum,average,range,stddev,percentile \
  percentile=95
# verify results:
v.info -c myzipcodes_wake
v.db.select myzipcodes_wake
v.univar myzipcodes_wake column=elev_range type=centroid

SEE ALSO

r.univar, v.univar, v.vect.stats, v.what.rast, v.what.rast3, v.what.vect

AUTHOR

Markus Neteler, CEA (for the EDEN EU/FP6 Project)

SOURCE CODE

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

Latest change: Friday Feb 28 22:32:36 2020 in commit: 787f55e56bd5aacaf7a8022a488a20d8a431a6b2


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

© 2003-2023 GRASS Development Team, GRASS GIS 7.8.9dev Reference Manual