[GRASS-user] v.net report -> table update

Moritz Lennert mlennert at club.worldonline.be
Tue Jul 7 05:18:13 EDT 2009


On 03/07/09 11:45, achim wrote:
> Hallo!
> 
> Is there an easy solution to insert values from v.net report into it's
> table?
> 
> I did it external with sqlite creating a new table from a join and
> connected my vectormap to that. But when I eg. add a node, I don't want
> to redo the hole procedure.
> 
> Information given from v.net nreport consists of cat and a list of cats
> from lines each node is connected to (see PS). It seems more complicated
> to update this inside grass. -> Is it useful to get to know how grass
> deals with nodes-lines in network internally??

No, not necessary. Just use a script such as this (assuming that the 
table linked to your map contains a start_cat and a stop_cat column 
defined as integer):

v.net YourMap operation=report | awk '{printf"UPDATE 
NameOfTableLinkedToYourMap set start_cat=%i,stop_cat=%i where 
cat=%i;\n", $2, $3, $1}' | db.execute

This can take quite some time if you have lots of lines in your network, 
so you can limit to the cat value of the new node with something like 
this (untested):

v.net YourMap operation=report | awk '{if($2==NewNodeCat || 
$3==NewNodeCat)printf"UPDATE NameOfTableLinkedToYourMap set 
start_cat=%i,stop_cat=%i where cat=%i;\n", $2, $3, $1}' | db.execute

Moritz


More information about the grass-user mailing list