Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
v.db.update(1)		    GRASS GIS User's Manual		v.db.update(1)

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
	   Print usage summary

       --verbose
	   Verbose module output

       --quiet
	   Quiet module	output

       --ui
	   Force launching GUI dialog

   Parameters:
       map=nameA [required]
	   Name	of vector map
	   Or data source for direct OGR access

       layer=stringA [required]
	   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 ac-
	   cess	this is	the layer name.
	   Default: 1

       column=nameA [required]
	   Name	of attribute column to update

       value=string
	   Literal value to update the column with

       query_column=name
	   Name	of other attribute column to query, can	be combination of col-
	   umns	(e.g. co1+col2)

       where=sql_query
	   WHERE conditions of SQL statement without 'where' keyword
	   Example: income < 1000 and population >= 10000

       sqliteextra=name
	   Name	 of  SQLite extension file for extra functions (SQLite backend
	   only)

DESCRIPTION
       v.db.update assigns a new value to a column in the attribute table con-
       nected  to a given map. The value parameter allows updating with	a lit-
       eral 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.

NOTES
       v.db.update is just a front-end to db.execute to	allow easier usage.

       For complex SQL UPDATE statements, db.execute should be used.

EXAMPLES
   Replacing of	NULL values
       In 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 WET-
       LAND:
       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 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	casting
       Type 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)" \
		   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 of libsqlitefunctions.so and	libsqlitefunc-
       tions.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)"	\
	 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.dropt-
       able, 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)

       Main index | Vector index | Topics index	| Keywords index  |  Graphical
       index | Full index

       A(C) 2003-2020 GRASS Development	Team, GRASS GIS	7.8.3 Reference	Manual

GRASS 7.8.3							v.db.update(1)

NAME | KEYWORDS | SYNOPSIS | DESCRIPTION | NOTES | EXAMPLES | SEE ALSO | AUTHOR | SOURCE CODE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=v.db.update&sektion=1&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help