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 the where keyword 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 output
    • json: JSON (JavaScript Object Notation)
    • shell: shell script style for Bash eval

πŸ’œ 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