[GRASS-user] Re: Connect two tables in vector data

Sebastian Schubert schubert.seb at googlemail.com
Tue Oct 11 04:26:53 EDT 2011

On Tuesday 11 October 2011 01:17:15 Richard Chirgwin wrote:
> On 11/10/11 4:02 PM, grass-user-request at lists.osgeo.org wrote:
> > Hi,
> > 
> > using 6.4.1, I imported a vector shape file which includes a
> > tables. This table got a "cat" column by grass (which I don't
> > need, I think) and already has a "key" column. In addition, I have
> > got another table which also has a "key" column. Using both "key"
> > columns, I want to combine both tables. How can I do that? I was
> > able connect, as a second layer, the additional table to the
> > vector data using the "key" column but then as far as I can see it
> > is not really connected to the first table.
> > 
> > I guess this is a standard procedure but I was not able to find the
> > solution.
> > 
> > Thanks
> > Sebastian
> Sebastian -
> I think you're asking to connect two tables to the same map?

Yes, I think so.

> The two tables need to refer to the same features, and you use
> v.db.connect
> Note that you can specify a different name for the key column using
> the key= parameter.

I think, this is what I tried. Here is what I did:

I imported the map baubloecke.shp. It already includes data (which is 
then called table "baubloecke":

GRASS 6.4.1 (Soldner):~ > v.db.connect -p baubloecke
Vector map <baubloecke at Berlin> is connected by:
layer <1> table <baubloecke> in database 
</home/schubert/grassdata/Soldner/Berlin/dbf/> through driver <dbf> with 
key <cat>

Ok, it is connected with key "cat" which has been introduced by grass, I 
think. The table "baubloecke" includes the column I want, as well as the 
table "bbdb":

GRASS 6.4.1 (Soldner):~ > db.columns baubloecke
GRASS 6.4.1 (Soldner):~ > db.columns bbdb

I connected bbdb to the map:

GRASS 6.4.1 (Soldner):~ > v.db.connect -o map=baubloecke table=bbdb 
key=SCHLUESSEL layer=2
The table <bbdb> is now part of vector map <baubloecke> and may be 
or overwritten by GRASS modules
Select privileges were granted on the table
GRASS 6.4.1 (Soldner):~ > v.db.connect -p baubloecke
Vector map <baubloecke at Berlin> is connected by:
layer <1> table <baubloecke> in database 
</home/schubert/grassdata/Soldner/Berlin/dbf/> through driver <dbf> with 
key <cat>
layer <2> table <bbdb> in database 
</home/schubert/grassdata/Soldner/Berlin/dbf/> through driver <dbf> with 

I tried to verify the connection using the wxpython gui. I opened the 
map there (tried both layer 1 and 2). Using the "Query raster/vector 
map(s)" tool, I was able to only get information from the layer 1 or the 
original table when clicking on a polygon.

Ok, maybe table 1 has to be connected also via the key "SCHLUESSEL" so I 

GRASS 6.4.1 (Soldner):~ > v.db.connect -o map=baubloecke 
table=baubloecke key=SCHLUESSEL layer=1
ERROR: Data type of key column must be integer
GRASS 6.4.1 (Soldner):~ > v.db.connect -o map=baubloecke 
table=baubloecke key=3 layer=1
ERROR: Missing column <3> in table <baubloecke>

I do not understand this... Apparently, grass does not accept the key 
SCHLUESSEL so I tried the number of the column (?) 3. No success, 

What can I do?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20111011/f38fa4d5/attachment.bin

More information about the grass-user mailing list