|
NAMEv.db.update - Updates a column in the attribute table connected to a vector map. KEYWORDSvector, attribute table, database, attribute update, type casting SYNOPSISv.db.update
Flags:Parameters:
DESCRIPTIONv.db.update assigns a new value to a column in the attribute table connected to a given map. The value parameter allows updating with a literal value. Alternatively, with the qcol parameter values can be copied from another column in the table or be the result of a combination or transformation of other columns. NOTESv.db.update is just a front-end to db.execute to allow easier usage. For complex SQL UPDATE statements, db.execute should be used. EXAMPLESReplacing of NULL valuesIn this example, selectively display lakes without (blue) and with
NULL (red) are shown to find out which type is undefined. In the original
map there are lakes missing FTYPE attribute which are wetlands along
streams. These 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 \ Updating of columns with on the fly calculationSpearfish example: adding new column, 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 castingType cast (type conversion) of strings to double precision
(unsupported by DBF driver):
g.copy vect=geodetic_pts,mygeodetic_pts v.db.update mygeodetic_pts col=zval qcol="CAST(z_value AS double precision)" \ 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 of libsqlitefunctions.so and libsqlitefunctions.dll). North Carolina data set example: adding new column, 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)" \ SEE ALSOdb.execute, v.db.addcolumn, v.db.addtable, v.db.connect, v.db.droptable, v.db.join, v.db.select GRASS SQL interface AUTHORMoritz Lennert (mlennert@club.worldonline.be) SOURCE CODEAvailable at: v.db.update source code (history) Latest change: Thursday Feb 03 11:10:06 2022 in commit: 547ff44e6aecfb4c9cbf6a4717fc14e521bec0be Main index | Vector index | Topics index | Keywords index | Graphical index | Full index © 2003-2025 GRASS Development Team, GRASS GIS 8.4.1 Reference Manual
|