[GRASS-dev] New addon in svn: v.db.calc

Massimiliano Cannata massimiliano.cannata at supsi.ch
Wed Jan 7 13:42:40 EST 2009


I just added the new script for field calculation.
It basically applies a python expression allowing the usage of field 
names as variables and update the selected column values.

It is useful for advanced field updates with DBF files.

An example:
Add a new column named EXP and populate it with the values of column 
"VAL" elevated at 0.25:
 > v.db.addcol map=myvector columns="EXP double"
 > v.db.calc input=myvector field=EXP exp="math.pow([VAL], 0.25)"

if the field is text:
Add a new text column named TXT and populte it concatenating <em> Dr. 
</em> and the text values of the column NAME where the TITLE is phd:
v.db.addcol map=owners columns="TXT varchar(25)"
v.db.calc input=owners field=TXT exp="'Dr. '+'[NAME]'" where="TITLE=phd"

It should virtually works with all the python libs, but I've just tested 
with math and common functions.
Please test and comment.

Maxi

-- 
-----------------------------------------------------
Dr. Massimiliano Cannata
Environmental & Geomatic Engineer

Institute of Earth Sciences - SUPSI
Trevano, C.P. 72, CH-6952 Canobbio, SWITZERLAND

Tel:    +41 (0)58 / 666 62 14  
Fax:    +41 (0)58 / 666 62 09
E-mail: massimiliano.cannata at supsi.ch

Web: 
http://www.ist.supsi.ch
http://istgis.ist.supsi.ch:8001/geomatica/
-------------------------------------------------------




More information about the grass-dev mailing list