Note: This document is for an older version of GRASS GIS that is outdated. You should upgrade, and read the current manual page.

GRASS logo

NAME

v.db.join - Joins a database table to a vector map table.

KEYWORDS

vector, database, attribute table

SYNOPSIS

v.db.join
v.db.join help
v.db.join [-ca] map=name [layer=integer] column=string otable=string ocolumn=string [--verbose] [--quiet]

Flags:

-c
Skip the join column in other table
-a
Add the suffix '_other' for the column names of otable
This is useful if you have columns with the same name in both tables
--verbose
Verbose module output
--quiet
Quiet module output

Parameters:

map=name
Vector map to which to join other table
layer=integer
Layer where to join
Default: 1
column=string
Join column in map table
otable=string
Other table name
ocolumn=string
Join column in other table

DESCRIPTION

v.db.join joins the content of another table into the connected attribute table of a vector map.

NOTES

v.db.join is a front-end to db.execute to allow easier usage. The vector attribute table must be stored in a SQL database (SQLite, PostgreSQL, MySQL, ODBC, ...). The DBF backend is not supported. Tables can be imported with db.in.ogr.

The vector map-database connection(s) can be verified with v.db.connect.

EXAMPLE

Joining the soil type explanations from table soils_legend into the Spearfish soils map (download legend):
g.copy vect=soils,mysoils

# import legend table
db.in.ogr soils_legend.csv out=soils_legend

# get join column names
v.info -c mysoils
db.describe -c soils_legend

# look at original table
v.db.select mysoils
cat|label
1|Aab
2|Ba
3|Bb
4|BcB
5|BcC
...

# look at legend
db.select soils_legend
db.select soils_legend | head -7
id|shortname|longname
0|no data|no data
0|AaB|Alice fine sandy loam, 0 to 6
0|Ba|Barnum silt loam
0|Bb|Barnum silt loam, channeled
0|BcB|Boneek silt loam, 2 to 6
0|BcC|Boneek silt loam, 6 to 9
...

# join soils_legend into mysoils attribute table
v.db.join mysoils col=label otable=soils_legend ocol=shortname

# verification of join
v.db.select mysoils
cat|label|id|shortname|longname
1|Aab|||
2|Ba|2|Ba|Barnum silt loam
3|Bb|3|Bb|Barnum silt loam, channeled
4|BcB|4|BcB|Boneek silt loam, 2 to 6
5|BcC|5|BcC|Boneek silt loam, 6 to 9
...

# join soils_legend into mysoils attribute table, escape shortname column that it is a duplicate of label; it add also _o suffix for the columns contained by soils_legend table
g.copy vect=soils,mysoils_ac
v.db.join -ac mysoils col=label otable=soils_legend ocol=shortname

# verification of join
v.db.select mysoils_ac
cat|label|id|longname_o
1|Aab|||
2|Ba|2|Barnum silt loam
3|Bb|3|Barnum silt loam, channeled
4|BcB|4|Boneek silt loam, 2 to 6
5|BcC|5|Boneek silt loam, 6 to 9

SEE ALSO

db.execute, db.in.ogr, v.db.update
GRASS SQL interface

AUTHOR

Markus Neteler

Last changed: $Date: 2012-02-01 05:56:19 -0800 (Wed, 01 Feb 2012) $


Main index - vector index - Full index

© 2003-2014 GRASS Development Team