CONNECTION OF A VECTOR MAP TO A DATABASE TABLE
Steps to follow:
|1. TRANSFORM VECTOR FILE FROM GRASS 5.0 TO GRASS 5.7 FORMAT
|2. DISPLAY VECTOR FILE
|3. CONNECT THE DATABASE
|4. LINK A DB TABLE TO THE VECTOR MAP
|5. DISPLAY DB CONTENTS QUERYING THE VECTOR MAP
To use GRASS 5.0 vector maps with the new GRASS 5.7, you first have to convert them to the new format: this can be made with v.convert.
For example, convert GRASS 5.0 "vect.strade.ext" vector map into GRASS 5.7 format "strade.ext".
Write v.convert on the console and the following form appears:
Fill the form with map names and press Run: a new vector map in GRASS 5.7 format is produced.
With GRASS 5.7 new Display Manager graphic interface a lot of display options and commands can be easily run.
Press the first button on the top left corner, and selected map(s) will be displayed in the active monitor.
To connect an external database to GRASS 5.7 just run db.connect on the terminal. Write the name of the database you want to connecgt to GRASS 5.7 and choose the right driver on the form: if you're using a PostgreSQL database you have to select pg driver.
The next step is to select a table from the database connected to GRASS 5.7, and link it to the vector map. To do this run v.db.connect.
In the v.db.connect form enter these options:
To extablish a connection between a vector map and a database table, map categories must match table keys or id of a certain field: the name of this field must be entered in the "key name" box of the form.
Press Run and on the form a warning appears: The table "table_name" is now part of vector map "map_name" and may be deleted or overwritten by GRASS modules.
To display database data simply by clicking on the related graphic object of the map, run d.what.vect command. This command can be run from the console or from the Display Manager (pressing this button): in both cases the cursor becomes a cross and allows to interactively query the map. When an object is selected, another form appears, displaying all related db data.
In the right form you can visualize all data (stored in the connected db table) linked to the selected vector object: these data can be erased or updated directly from the form.