.TH r.univar 1grass "" "GRASS 6.4.4" "Grass User's Manual" .SH NAME \fI\fBr.univar\fR\fR - Calculates univariate statistics from the non-null cells of a raster map. .SH KEYWORDS raster, statistics .SH SYNOPSIS \fBr.univar\fR .br \fBr.univar help\fR .br \fBr.univar\fR [\-\fBget\fR] \fBmap\fR=\fIname\fR[,\fIname\fR,...] [\fBzones\fR=\fIname\fR] [\fBoutput\fR=\fIname\fR] [\fBpercentile\fR=\fIfloat\fR[,\fIfloat\fR,...]] [\fBfs\fR=\fIcharacter\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] .SS Flags: .IP "\fB\-g\fR" 4m .br Print the stats in shell script style .IP "\fB\-e\fR" 4m .br Calculate extended statistics .IP "\fB\-t\fR" 4m .br Table output format instead of standard output format .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .PP .SS Parameters: .IP "\fBmap\fR=\fIname[,\fIname\fR,...]\fR" 4m .br Name of input raster map(s) .IP "\fBzones\fR=\fIname\fR" 4m .br Raster map used for zoning, must be of type CELL .IP "\fBoutput\fR=\fIname\fR" 4m .br Name for output file (if omitted or "-" output to stdout) .IP "\fBpercentile\fR=\fIfloat[,\fIfloat\fR,...]\fR" 4m .br Percentile to calculate (requires extended statistics flag) .br Options: \fI0-100\fR .br Default: \fI90\fR .IP "\fBfs\fR=\fIcharacter\fR" 4m .br Field separator .br Special characters: space, comma, tab .br Default: \fI|\fR .PP .SH DESCRIPTION \fIr.univar\fR 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, and coefficient of variation. Statistics are calculated separately for every category/zone found in the \fBzones\fR input map if given. If the \fB-e\fR extended statistics flag is given the 1st quartile, median, 3rd quartile, and given \fBpercentile\fR are calculated. If the \fB-g\fR flag is given the results are presented in a format suitable for use in a shell script. If the \fB-t\fR 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 \fBzones\fR input raster. .PP When multiple input maps are given to \fIr.univar\fR, 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 \fIr.series\fR or \fIr.patch\fR. .SH NOTES As with most GRASS raster modules, \fIr.univar\fR operates on the raster array defined by the current region settings, not the original extent and resolution of the input map. See \fIg.region\fR. .PP This module can use large amounts of system memory when the \fB-e\fR 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. .PP Without a \fBzones\fR input raster, the \fIr.quantile\fR module will be significantly more efficient for calculating percentiles with large maps. .SH EXAMPLE Calculate the raster statistics for zones within a vector map coverage and upload the results for mean, min and max back to the vector map: \fC .DS .br #### set the raster region to match the map .br g.region vect=fields res=10 \-ap .br .br #### create rasterized version of vector map .br v.to.rast in=fields out=fields.10m use=cat type=area labelcolumn=label .br r.colors fields.10m color=random .br .br #### perform analysis .br r.univar \-t map=elevation.10m zones=fields.10m | \(rs .br cut \-f1,5,6,8 \-d'|' > fields_stats.txt .br .br .br #### populate vector DB with stats .br .br # create working copy of vector map .br g.copy vect=fields,fields_stats .br .br # create new attribute columns to hold output .br v.db.addcol map=fields_stats \(rs .br columns='mean_elev DOUBLE PRECISION, min_elev DOUBLE PRECISION, max_elev DOUBLE PRECISION' .br .br # create SQL command file, and execute it .br sed \-e '1d' fields_stats.txt | awk -F'|' \(rs .br '{print "UPDATE fields_stats SET min_elev = "$2", max_elev = "$3", \(rs .br mean_elev = "$4" WHERE cat = "$1";"}' \(rs .br > fields_stats_sqlcmd.txt .br .br db.execute input=fields_stats_sqlcmd.txt .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br .br #### view completed table .br v.db.select fields_stats .br .DE \fR .SH TODO \fImode, skewness, kurtosis\fR .SH SEE ALSO \fI g.region, r3.univar, r.average, r.median, r.mode, r.quantile, r.sum, r.series, r.stats, v.rast.stats, r.statistics, v.univar \fR .SH AUTHORS Hamish Bowman, Otago University, New Zealand .br Extended statistics by Martin Landa .br Multiple input map support by Ivan Shmakov .br Zonal loop by Markus Metz .PP \fILast changed: $Date: 2012-08-14 11:11:23 +0200 (Tue, 14 Aug 2012) $\fR .PP Full index .PP © 2003-2014 GRASS Development Team