[GRASS-user] Adding rows to vector map attribute table

Moritz Lennert mlennert at club.worldonline.be
Tue Apr 24 03:48:09 EDT 2012


On 23/04/12 20:16, Rich Shepard wrote:
>   I have a few dozen points to add to a vector map and can do this most
> easily using the SQL 'INSERT INTO ...' syntax directly on the postgres
> table. Does GRASS automagically update the cat column, or do I do this as
> part of the insert statement?

As others have already said, you have to differentiated between the 
insertion of the geometry (i.e. the point) and the insertion of 
attribute information.

For the insertion of new points into an existing map, GRASS offers 
different solutions:

- v.digit for manual digitalisation of points
- v.edit tool=add (using a text file or standard input with points given 
in GRASS ascii standard (not point !) format)
- v.in.ascii + v.patch

In terms of attributes, if your new points have the exact same 
attributes as the existing points, v.in.ascii + v.patch is probably the 
easiest: just put your points into a csv file with all attributes, use 
the columns= parameter of v.in.ascii to correctly define the columns so 
that they match the existing ones, drop the x and y columns after import 
with v.db.dropcol and then v.patch the newly imported points into the 
existing ones, using the -e flag to keep the attributes. You can also 
use the -a flag of v.patch to append the data into the existing map.

If you have added points with categories (e.g. through v.edit), but 
without an entry in the table, you can then just insert an entry with 
just a category number into the attribute table with v.to.db and then 
add the values into the other attribute columns with v.db.update. Or you 
can just insert everything (category value included) with a standard 
INSERT INTO statement.

I guess a "existing map to which data should be appended" parameter in 
v.in.ascii / v.in.ogr would be nice.

Moritz


More information about the grass-user mailing list