v.univar(1grass)
π v.univar β the GRASS manual page, but make it a group chat β¨
okay so. this is the manual page for v.univar from the GRASS User's Manual (yes, the v.univar(1grass) one, hi bestie π«Ά). she calculates stuff. a LOT of stuff. let's get into it.
β¨ NAME β¨
v.univar β Calculates univariate statistics of vector map features. Variance and standard deviation is calculated only for points if specified.
π·οΈ KEYWORDS π·οΈ
vector, statistics, univariate statistics, attribute table, geometry
πΈ SYNOPSIS πΈ
v.univar
v.univar --help
v.univar [-gewd] map=name [layer=string] [type=string[,string,...]]
[column=name] [where=sql_query] [percentile=integer] format=name
[--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. (rip bestie, she's on her way out π)-eβ Calculate extended statistics. yes queen, give us MORE numbers π-wβ Weigh by line length or area size.-dβ Calculate geometric distances instead of attribute statistics.--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.type=string[,string,...]β Input feature type. Options:point,line,boundary,centroid,area. Default:point,line,area.column=nameβ Name of attribute column.where=sql_queryβ WHERE conditions of SQL statement without 'where' keyword. Example:income < 1000 and population >= 10000.percentile=integerβ Percentile to calculate (requires extended statistics flag). Options:0-100. Default:90.format=name[required] β Output format. Options:plain,shell,json. Default:plain.plain: Human readable text outputshell: shell script style text outputjson: JSON (JavaScript Object Notation)
π DESCRIPTION π
So v.univar calculates univariate statistics on β by default β an attribute of vector map features, or, through the -d flag, on the distance between vector map features. periodt. β¨
Here's the tea on how attributes get read: they're read per feature and per category value. Which means if your map has several features sitting on the same category value, that attribute gets read as many times as there are features. and, on the flip side, if one feature has more than one category value, then each attribute value linked to each of those category values of the feature gets read. yeah. she's thorough like that.
If what you actually want is stats on one attribute per category value instead of one attribute per feature and per category? that's a different girl. go see v.db.univar. π
Extended statistics (-e) adds median, 1st and 3rd quartiles, and the 90th percentile to the output. she ate.
π NOTES π
When you use the -d flag, univariate statistics of distances between vector features are calculated. The distances from all features to all other features are used. And here's why that doesn't double count: since the distance from feature A to feature B is the same like the distance from feature B to feature A, that distance is considered only once β i.e. all pairwise distances between features are used. no cap.
Depending on the selected vector type, distances are calculated as follows:
type=point: point distances are considered;type=line: line to line distances are considered;type=area: not supported, usetype=centroidinstead (and seev.distancefor calculating distances between areas). like, genuinely not supported, don't fight her on this π
π EXAMPLES π
The examples are based on the North Carolina sample dataset.
π Example dataset preparation
g.region raster=elevation -p
v.random output=samples npoints=100
v.db.addtable map=samples columns="heights double precision"
v.what.rast map=samples rast=elevation column=heights
v.db.select map=samples
π Calculate height attribute statistics
v.univar -e samples column=heights type=point
number of features with non NULL attribute: 100
number of missing attributes: 0
number of NULL attributes: 0
minimum: 57.2799
maximum: 148.903
range: 91.6235
sum: 10825.6
mean: 108.256
mean of absolute values: 108.256
population standard deviation: 20.2572
population variance: 410.356
population coefficient of variation: 0.187123
sample standard deviation: 20.3593
sample variance: 414.501
kurtosis: -0.856767
skewness: 0.162093
1st quartile: 90.531
median (even number of cells): 106.518
3rd quartile: 126.274
90th percentile: 135.023
π Compare to statistics of original raster map
r.univar -e elevation
total null and non-null cells: 2025000
total null cells: 0
Of the non-null cells:
----------------------
n: 2025000
minimum: 55.5788
maximum: 156.33
range: 100.751
mean: 110.375
mean of absolute values: 110.375
standard deviation: 20.3153
variance: 412.712
variation coefficient: 18.4057 %
sum: 223510266.558102
1st quartile: 94.79
median (even number of cells): 108.88
3rd quartile: 126.792
90th percentile: 138.66
π Calculate statistic of distance between sampling points
v.univar -d samples type=point
number of primitives: 100
number of non zero distances: 4851
number of zero distances: 0
minimum: 69.9038
maximum: 18727.7
range: 18657.8
sum: 3.51907e+07
mean: 7254.33
mean of absolute values: 7254.33
population standard deviation: 3468.53
population variance: 1.20307e+07
population coefficient of variation: 0.478132
sample standard deviation: 3468.89
sample variance: 1.20332e+07
kurtosis: -0.605406
skewness: 0.238688
π Output in JSON format
v.univar -e samples column=heights type=point format=json
will output the results in JSON format:
{
"n": 1832,
"missing": 0,
"nnull": 0,
"min": 166.946991,
"max": 2729482.25,
"range": 2729315.3030090001,
"sum": 78876146.145385057,
"mean": 43054.664926520229,
"mean_abs": 43054.664926520229,
"population_stddev": 132689.08650029532,
"population_variance": 17606393676.282852,
"population_coeff_variation": 3.0818747916573215,
"sample_stddev": 132725.31560308655,
"sample_variance": 17616009401.938931,
"kurtosis": 139.15698418811229,
"skewness": 9.7065048189730767,
"first_quartile": 3699.3234859999998,
"median": 10308.4453125,
"third_quartile": 29259.074218999998,
"percentiles": [
{
"percentile": 90,
"value": 86449.734375
}
]
}
π SEE ALSO π
db.univar, r.univar, v.db.univar, v.distance, v.neighbors, v.qcount
π AUTHORS π
Radim Blazek, ITC-irst
extended by: Hamish Bowman, University of Otago, New Zealand Martin Landa
πΎ SOURCE CODE πΎ
Available at: v.univar source code (history)
Latest change: Thursday Oct 02 14:39:13 2025 in commit: 1850489bf42c72d8dcfe2e4db1738441b4a7dc43
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie, no cap, every single number accounted for π«Άβ¨
okay so before you go β huge shoutout to the GRASS Development Team, Β© 2003-2026, GRASS 8.5.0 Reference Manual. this was GRASS 8.5.0, and the last touch was Thursday Oct 02 14:39:13 2025. iconic. bye bestie, go run your stats ππΈπ¦
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- 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