v.db.update(1)
π v.db.update π
okay so bestie, gather round, because this is v.db.update(1) from the GRASS GIS User's Manual (you're on GRASS 8.4.2, no cap) and it is literally the glow-up tool for your attribute tables. it updates a column in the attribute table connected to a vector map. that's the whole vibe. β¨
πΈ NAME πΈ
v.db.update β updates a column in the attribute table connected to a vector map.
π KEYWORDS π
vector, attribute table, database, attribute update, type casting
β¨ SYNOPSIS β¨
v.db.update
v.db.update --help
v.db.update map=name layer=string column=name [value=string]
[query_column=name] [where=sql_query] [sqliteextra=name] [--help]
[--verbose] [--quiet] [--ui]
π¦ Flags
--helpβ prints the usage summary, i.e. the "what is this" card for when you forgot.--verboseβ verbose module output. she's chatty.--quietβ quiet module output. she's mysterious.--uiβ force launches the GUI dialog. main character energy, but make it clickable.
π Parameters
map=name[required] β the name of the vector map. or, plot twist, a data source for direct OGR access.layer=string[required] β layer number or name. vector features can have category values in different layers, and this number determines which layer to use. when you're doing direct OGR access, this is the layer name instead. Default:1column=name[required] β the name of the attribute column you're updating. yes, this one. this is the one.value=stringβ a literal value to update the column with. just plop it right in there.query_column=nameβ the name of another attribute column to query. it can be a combination of columns too, likeco1+col2. (you'll see it written asqcol=in the examples below, iykyk.)where=sql_queryβ WHERE conditions of the SQL statement, without thewherekeyword. Example:income < 1000 and population >= 10000sqliteextra=nameβ name of the SQLite extension file for extra functions (SQLite backend only).
π DESCRIPTION π
v.db.update assigns a new value to a column in the attribute table connected to a given map. the value parameter lets you update with a literal value. alternatively, with the query_column parameter, values can be copied from another column in the table, or they can be the result of a combination or transformation of other columns. it's giving flexible. it's giving powerful. it's giving database wizardry.
π₯ NOTES π₯
v.db.update is just a front-end to db.execute, so it can be easier to use. that's it, that's the tea. π«
for complex SQLUPDATEstatements,db.executeshould be used. like, actually use it. don't come for me later.
π EXAMPLES π
π Replacing of NULL values
in this example, selectively displaying lakes without (blue) and with NULL (red) are shown so you can find out which type is undefined. in the original map there are lakes missing the FTYPE attribute which are wetlands along streams. those NULL attributes are replaced with the landuse type WETLAND:
g.copy vect=lakes,mylakes
v.db.select mylakes
v.db.select mylakes where="FTYPE IS NULL"
# display the lakes, show undefined FTYPE lakes in red
g.region vector=mylakes
d.mon wx0
d.vect mylakes where="FTYPE NOT NULL" type=area col=blue
d.vect mylakes where="FTYPE IS NULL" type=area col=red
# replace NULL with FTYPE WETLAND
v.db.update mylakes col=FTYPE value=WETLAND \
where="FTYPE IS NULL"
v.db.select mylakes
π Updating of columns with on the fly calculation
Spearfish example: adding a new column, then copying values from another table column with on the fly calculation:
g.copy vect=fields,myfields
v.db.addcolumn myfields col="polynum integer"
v.db.update myfields col=polynum qcol="cat*2"
v.db.select myfields
π§ Type casting
type cast (type conversion) of strings to double precision β heads up, this is unsupported by the DBF driver:
g.copy vect=geodetic_pts,mygeodetic_pts
v.db.update mygeodetic_pts col=zval qcol="CAST(z_value AS double precision)" \
where="z_value <> 'N/A'"
β Updating of columns with on the fly calculation (SQLite extended functions)
Note: this requires SQLite extended functions. for details see the GRASS GIS Wiki (compilation oflibsqlitefunctions.soandlibsqlitefunctions.dll).
North Carolina data set example: adding a new column, then copying values from another table column with on the fly calculation:
g.copy vect=precip_30ynormals,myprecip_30ynormals
v.db.addcolumn myprecip_30ynormals column="logjuly double precision"
v.db.update myprecip_30ynormals column="logjuly" query_column="log(jul)" \
sqliteextra=$HOME/sqlite_extensions/libsqlitefunctions.so
v.db.select myprecip_30ynormals columns=jul,logjuly
jul|logjuly
132.842|4.88916045210132
127|4.84418708645859
124.206|4.82194147751127
104.648|4.65060233738593
98.298|4.58800368106618
...
π SEE ALSO π
db.execute, v.db.addcolumn, v.db.addtable, v.db.connect, v.db.droptable, v.db.join, v.db.select
GRASS SQL interface
π«Ά AUTHOR π«Ά
Moritz Lennert (mlennert@club.worldonline.be)
π SOURCE CODE π
Available at: v.db.update source code (history)
Accessed: Saturday Jan 17 05:41:53 2026
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole page bestie π β¨ shoutout to the GRASS Development Team for the Β© 2003-2025 and the GRASS GIS 8.4.2 Reference Manual, accessed Saturday Jan 17 05:41:53 2026 β you ate, fr fr. now go update that column. periodt. ππ¦
π¦ 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