[GRASS-user] Integrating multi tables

Moritz Lennert mlennert at club.worldonline.be
Mon Mar 26 04:50:13 EDT 2007


On 24/03/07 07:34, Richard Chirgwin wrote:
> Trying to work this one out, and not getting anywhere!
> 
> I have imported Shapefiles into vector maps.
> 
> I have "population" data (not people but using the same cat column IDs 
> as in the shapefile attribute tables).
> 
> How do I integrate the population data so that the shapefiles can be 
> coloured in thematic maps?
> 
> I can add columns to the vector attribute tables - but I can't find a 
> command that would mass-populate the column
> (in MySQL it would be a simple UPDATE Table 1, Table 2 set column=column 
> where table 1.cat=table 2.cat).
> 
> (It probably doesn't help that the population data is in MySQL but I am 
> happy to import)
> 
> I fear that I am missing something *really* simple but am just about 
> going spare trying to find out!

If you are using the default GRASS settings, your shapefile data gets 
imported as a dbf file. There is no way of combining this file with 
others, either in a database application or in GRASS (i.e. there is no 
equivalent of ArcView's "joining" tables).
However, you are not obliged to work with dbf files, you can import your 
shapefile attribute data into mysql and then either add the colums with 
your above 'update' command or just create a view combining the two 
tables and link your map to this view.

Use:

- db.connect to define a different database backend (Databases->Manage 
Databases->Connect to database in the GUI)
- db.copy to copy an existing table to another table, including between 
different backends, i.e. dbf to mysql (Databases->Manage Databases->Copy 
table)
- v.db.connect to link your map to the table or to the view 
(Vector->vector<->database connection->Set database connection...)

You can also begin by setting db.connect in a new location, and then 
import the shapefile with v.in.ogr. The attribute table is then 
automatically created in the database you connected to.

Moritz




More information about the grass-user mailing list