v.db.univar(1)
π v.db.univar β the manual page, bestie edition π
okay so this is v.db.univar(1), straight out of the GRASS GIS User's Manual, and it's literally here to hand you univariate stats on a column in your vector map's attribute table. no cap. π«Ά
β¨ NAME β¨
v.db.univar β calculates univariate statistics on selected table column for a GRASS vector map. that's the whole job. it does the math so you don't have to. π
π·οΈ KEYWORDS π·οΈ
vector, statistics, attribute table β yes bestie, those are the tags. iykyk.
πΈ SYNOPSIS πΈ
v.db.univar
v.db.univar --help
v.db.univar [-eg] map=name [layer=string] column=name
[where=sql_query] [percentile=float[,float,...]] [format=string]
[--help] [--verbose] [--quiet] [--ui]
π Flags π
-eβ extended statistics (quartiles and 90th percentile). it's giving extra credit energy.-gβ print stats in shell script style. perfect for piping straight into your scripts, slay.--helpβ print usage summary. the little cry for help we all need sometimes.--verboseβ verbose module output. it will not shut up (affectionate).--quietβ quiet module output. the opposite vibe entirely.--uiβ force launching GUI dialog. for when you want buttons instead of typing.
π¦ Parameters π¦
map=name[required] β name of vector map. or, plot twist, a data source for direct OGR access.layer=stringβ layer number or name. vector features can have category values in different layers, and this number decides which layer we're talking to. when you're doing direct OGR access, this is the layer name instead. default:1.column=name[required] β name of the attribute column you want stats on. it must be numeric, so don't come at it with text, it will not eat that.where=sql_queryβ WHERE conditions of an SQL statement, but without thewherekeyword itself. example:income < 1000 and population >= 10000. yes bestie, filter your little heart out.percentile=float[,float,...]β percentile to calculate. it requires the extended statistics flag (-e), so don't try it solo, it's codependent. options:0-100. default:90.format=stringβ output format. options:plain,json,shell.plain: plain text outputjson: JSON (JavaScript Object Notation)shell: shell script style for Basheval
π DESCRIPTION π
v.db.univar calculates basic univariate statistics for numeric attributes in a vector attribute table. it will calculate minimum, maximum, range, mean, standard deviation, variance, coefficient of variation, quartiles, median, and 90th percentile. that's a whole lot of numbers and honestly? iconic. π
v.db.univar uses db.univar, which in turn uses db.select to get the attribute values it then calculates the statistics on. so what does that mean for you? it means the statistics are calculated based on the entries in the attribute table, NOT based on the features in the map. one attribute value gets read from each line in the attribute table β whether there are no, one or several features with the category value that line references, or whether any features have more than one category value. it does not care. it reads lines. periodt.
if you want feature-based univariate statistics on attributes instead of attribute-table-based ones, go look at v.univar instead. different girl, different job. π
π NOTES π
a database connection must be defined for the selected vector layer. no connection, no stats. it's giving "no wifi, no vibes." π
π EXAMPLES π
π Univariate statistics on attribute table column
in this example, the 30 years precipitation data table is statistically analysed (North Carolina sample dataset) and univariate statistics performed:
# show columns of attribute table connected to precipitation map
v.info -c precip_30ynormals
# univariate statistics on 30 years annual precipitation in NC
v.db.univar precip_30ynormals column=annual
Number of values: 136
Minimum: 947.42
Maximum: 2329.18
Range: 1381.76
Mean: 1289.31147058823
[...]
look at those numbers. they ate. π₯
π§ Univariate statistics on randomly sampled data points
in this example, random points are sampled from the elevation map (North Carolina sample dataset) and univariate statistics performed:
g.region raster=elevation -p
v.random output=samples n=100
v.db.addtable samples column="heights double precision"
v.what.rast samples raster=elevation column=heights
v.db.select samples
v.db.univar samples column=heights
sample, add a table, pull the raster values in, peek at them, then get your stats. a whole little workflow, and it's adorable. π
β JSON output
this uses the JSON output of the module, which is passed using a pipe (in Bash or other unix-like shell) to the jq tool, which selects just the relevant statistic.
v.db.univar precip_30ynormals column=annual format=json | jq .statistics.mean
one number, zero noise. main character energy. β¨
π SEE ALSO π
db.univar, r.univar, v.univar, db.select, d.vect.thematic, v.random
GRASS SQL interface
π«Ά AUTHORS π«Ά
Michael Barton, Arizona State University
and authors of r.univar.sh (Markus Neteler et al.)
π» SOURCE CODE π»
available at: v.db.univar source code (history)
accessed: Saturday Jan 17 05:41:53 2026
main index | vector index | topics index | keywords index | graphical index | full index
and that's the whole page, bestie!! π this manual page is part of GRASS GIS 8.4.2 (Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual) β you can find it filed under v.db.univar(1) in the GRASS 8.4.2 docs. now go calculate some statistics, you absolute legend. π
πΈβ¨
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· 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