r3.univar(1grass)
π r3.univar π
okay bestie, this is the GRASS User's Manual page for r3.univar, and I'm about to make 3D raster statistics the most fun you've had all week. no cap.
β¨ NAME β¨
r3.univar β Calculates univariate statistics from the non-null cells of a 3D 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 π·οΈ
raster3d, statistics, univariate statistics
π¦ SYNOPSIS π¦
r3.univar
r3.univar --help
r3.univar [-get] map=name [zones=name] [output=name]
[percentile=float[,float,...]] [separator=character] format=name
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π Flags:
-gβ Print the stats in shell script style [deprecated]. This flag is deprecated and will be removed in a future release. Useformat=shellinstead.-eβ Calculate extended statistics.-tβ Table output format instead of standard output format [deprecated]. This flag is deprecated and will be removed in a future release. Useformat=csvinstead.--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[required]β Name of 3D raster map.zones=nameβ 3D Raster map used for zoning, must be of typeCELL.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.format=name[required]β Output format. Options:plain,shell,csv,json. Default:plain.plain: Human readable text outputshell: shell script style text outputcsv: CSV (Comma Separated Values)json: JSON (JavaScript Object Notation)
π DESCRIPTION π
So r3.univar calculates the univariate statistics for a 3D raster map. that's the whole vibe. it gives you the number of cells counted, minimum and maximum cell values, range, arithmetic mean, population variance, standard deviation, coefficient of variation, and sum. iconic behavior tbh.
here's the tea tho: statistics are calculated separately for every category/zone found in the zones input map if you give one. so you can get per-zone stats and it's lowkey amazing.
- if you pass the
-eextended statistics flag, you also get the 1st quartile, median, 3rd quartile, and given percentile. obsessed. - if you pass the
-gflag, results come out in a format suitable for use in a shell script. - if you pass the
-tflag, results are presented in tabular format with the given field separator.
and here's the part where it gets really cute β that 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. full circle moment fr fr. π₯
π NOTES π
- As with most GRASS raster3d modules,
r3.univaroperates on the voxel array defined by the current 3d region settings, not the original extent and resolution of the input map. Seeg.region. - This module can use large amounts of system memory when the
-eextended 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.
ngl the memory thing is real, bestie β if your region is huge and you're using -e, watch out. it should bow out gracefully with a memory allocation error but likeβ¦ maybe don't test it on purpose π
π EXAMPLE π
Computing univariate statistics of a 3D raster with randomly generated values:
# define volume
g.region n=10 s=0 w=0 e=10 b=0 t=10 res=1 res3=1 -p3
# generate random map
r3.mapcalc "random_0_1 = rand(0., 1)"
# compute univariate statistics, along with extended statistics
r3.univar -e map=random_0_1 percentile=98
100%
total null and non-null cells: 1000
total null cells: 0
Of the non-null cells:
----------------------
n: 1000
minimum: 0.00053905
maximum: 0.998322
range: 0.997783
mean: 0.513676
mean of absolute values: 0.513676
standard deviation: 0.289969
variance: 0.0840821
variation coefficient: 56.4498 %
sum: 513.676463040334
1st quartile: 0.257654
median (even number of cells): 0.524313
3rd quartile: 0.763637
98th percentile: 0.982924
# script style output, along with extended statistics
r3.univar -ge map=random_0_1 percentile=98
n=1000
null_cells=0
cells=1000
min=0.000539049520323687
max=0.998322037540536
range=0.997782988020212
mean=0.513676463040334
mean_of_abs=0.513676463040334
stddev=0.289969154194666
variance=0.0840821103843701
coeff_var=56.4497646005434
sum=513.676463040334
first_quartile=0.257654
median=0.524313
third_quartile=0.763637
percentile_98=0.982924
π§ TODO π§
To be implemented mode, skewness, kurtosis.
coming soon(ish) to a module near you π
π SEE ALSO π
g.region, r.univar, r.mode, r.quantile, r.series, r3.stats, r.statistics, v.rast.stats, v.univar
π«Ά AUTHORS π«Ά
- Soeren Gebbert
- Code is based on
r.univarfrom Hamish Bowman, Otago University, New Zealand and Martin Landa - Zonal loop by Markus Metz
π» SOURCE CODE π»
Available at: r3.univar source code (history)
Accessed: Tuesday Sep 08 11:54:43 2026
Main index | 3D raster index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
and that's the whole page bestie!! this was r3.univar from GRASS 8.5.0 in the GRASS User's Manual, manual page r3.univar(1grass). go calculate some voxels and slay π
β¨π
π¦ where this page comes from
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms