GRASS logo

NAME

r.univar - Calculates univariate statistics from the non-null cells of a raster map.
Statistics include number of cells counted, minimum and maximum cell values, range, arithmetic mean, population variance, standard deviation, coefficient of variation, and sum.

KEYWORDS

raster, statistics, univariate statistics, zonal statistics

SYNOPSIS

r.univar
r.univar --help
r.univar [-get] map=name[,name,...] [zones=name] [output=name] [percentile=float[,float,...]] [separator=character] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-g
Print the stats in shell script style
-e
Calculate extended statistics
-t
Table output format instead of standard output format
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

map=name[,name,...] [required]
Name of raster map(s)
zones=name
Raster map used for zoning, must be of type CELL
output=name
Name for output file (if omitted or "-" output to stdout)
percentile=float[,float,...]
Percentile to calculate (requires extended statistics flag)
Options: 0-100
Default: 90
separator=character
Field separator
Special characters: pipe, comma, space, tab, newline
Default: pipe

Table of contents

DESCRIPTION

r.univar calculates the univariate statistics of one or several raster map(s). This includes the number of cells counted, minimum and maximum cell values, range, arithmetic mean, population variance, standard deviation, coefficient of variation, and sum. Statistics are calculated separately for every category/zone found in the zones input map if given. If the -e extended statistics flag is given the 1st quartile, median, 3rd quartile, and given percentile are calculated. If the -g flag is given the results are presented in a format suitable for use in a shell script. If the -t flag is given the results are presented in tabular format with the given field separator. The table can immediately be converted to a vector attribute table which can then be linked to a vector, e.g. the vector that was rasterized to create the zones input raster.

When multiple input maps are given to r.univar, the overall statistics are calculated. This is useful for a time series of the same variable, as well as for the case of a segmented/tiled dataset. Allowing multiple raster maps to be specified saves the user from using a temporary raster map for the result of r.series or r.patch.

NOTES

As with most GRASS raster modules, r.univar operates on the raster array defined by the current region settings, not the original extent and resolution of the input map. See g.region.

This module can use large amounts of system memory when the -e extended statistics flag is used with a very large region setting. If the region is too large the module should exit gracefully with a memory allocation error. Basic statistics can be calculated using any size input region.

Without a zones input raster, the r.quantile module will be significantly more efficient for calculating percentiles with large maps.

For calculating univariate statistics from a raster map based on vector polygon map and uploads statistics to new attribute columns, see v.rast.stats.

EXAMPLE

Calculate the raster statistics for zones within a raster polygon map coverage (basins, North Carolina sample dataset):
# set computational region
g.region raster=basin -p

# check basin IDs
r.category basin

#### perform analysis with elevation map (extent and res. match)
r.univar -t map=elevation zones=basin separator=comma \
         output=basin_elev_zonal.csv

TODO

mode, skewness, kurtosis

SEE ALSO

g.region, r3.univar, r.mode, r.quantile, r.series, r.stats, r.stats.quantile, r.stats.zonal, r.statistics, v.rast.stats, v.univar

AUTHORS

Hamish Bowman, Otago University, New Zealand
Extended statistics by Martin Landa
Multiple input map support by Ivan Shmakov
Zonal loop by Markus Metz

Last changed: $Date: 2014-12-19 22:55:37 +0100 (Fri, 19 Dec 2014) $


Main index | Raster index | Topics index | Keywords index | Full index

© 2003-2015 GRASS Development Team, GRASS GIS 7.0.1 Reference Manual