1v.db.join(1) GRASS GIS User's Manual v.db.join(1)
2
3
4
6 v.db.join - Joins a database table to a vector map table.
7
9 vector, attribute table, database
10
12 v.db.join
13 v.db.join --help
14 v.db.join map=name [layer=string] column=name other_table=name
15 other_column=name [subset_columns=name[,name,...]] [--help] [--ver‐
16 bose] [--quiet] [--ui]
17
18 Flags:
19 --help
20 Print usage summary
21
22 --verbose
23 Verbose module output
24
25 --quiet
26 Quiet module output
27
28 --ui
29 Force launching GUI dialog
30
31 Parameters:
32 map=name [required]
33 Name of vector map
34 Vector map to which to join other table
35
36 layer=string
37 Layer number or name
38 Layer where to join
39 Default: 1
40
41 column=name [required]
42 Identifier column (e.g.: cat) in the vector table to be used for
43 join
44
45 other_table=name [required]
46 Other table name
47
48 other_column=name [required]
49 Identifier column (e.g.: id) in the other table used for join
50
51 subset_columns=name[,name,...]
52 Subset of columns from the other table
53
55 v.db.join joins the content of another table into the connected attri‐
56 bute table of a vector map.
57
59 v.db.join is a front-end to db.execute to allow easier usage. The vec‐
60 tor attribute table must be stored in a SQL database (SQLite, Post‐
61 greSQL, MySQL, ODBC, ...). The DBF backend is not supported. Tables can
62 be imported with db.in.ogr.
63
64 The vector map-database connection(s) can be verified with v.db.con‐
65 nect.
66
68 Exercise to join North Carolina geological classes from a CSV table to
69 the "geology" map of the North Carolina sample dataset (requires down‐
70 load of legend CSV file nc_geology.csv from External data for NC sample
71 dataset):
72 # check original map attributes
73 v.db.select geology column=GEO_NAME,SHAPE_area
74 # import of CSV table
75 db.in.ogr input=nc_geology.csv output=nc_geology
76 # work on copy of geology map in current mapset
77 g.copy vector=geology,mygeology
78 # check column names of vector map attributes
79 v.info -c mygeology
80 # check column names of legend table
81 db.describe -c nc_geology
82 # join table using key columns (map: "GEO_NAME"; table: "geol_id")
83 v.db.join map=mygeology column=GEO_NAME other_table=nc_geology other_column=geol_id
84 # verify result (here abbreviated)
85 v.db.select mygeology | head -3
86 cat|onemap_pro|PERIMETER|GEOL250_|GEOL250_ID|GEO_NAME|SHAPE_area|SHAPE_len|geol_id|longname|comment
87 1|963738.75|4083.97998|2|1|Zml|963738.608571|4083.979839|Zml|Metagraywacke|Interlayered with metaconglomerate, ...
88 2|22189124|26628.261719|3|2|Zmf|22189123.2296|26628.261112|Zmf|Metafelsite|Light-colored porphyritic extrusive rock
89 ...
90
91 Soil map table join
92 Joining the soil type explanations from table soils_legend into the
93 Spearfish soils map (download legend):
94 g.copy vect=soils,mysoils
95 # import legend table
96 db.in.ogr soils_legend.csv out=soils_legend
97 # get join column names
98 v.info -c mysoils
99 db.describe -c soils_legend
100 # look at original table
101 v.db.select mysoils
102 cat|label
103 1|Aab
104 2|Ba
105 3|Bb
106 4|BcB
107 5|BcC
108 ...
109 # look at legend
110 db.select table=soils_legend
111 db.select table=soils_legend | head -7
112 id|shortname|longname
113 0|no data|no data
114 0|AaB|Alice fine sandy loam, 0 to 6
115 0|Ba|Barnum silt loam
116 0|Bb|Barnum silt loam, channeled
117 0|BcB|Boneek silt loam, 2 to 6
118 0|BcC|Boneek silt loam, 6 to 9
119 ...
120 # join soils_legend into mysoils attribute table
121 v.db.join mysoils col=label other_table=soils_legend ocol=shortname
122 # verification of join
123 v.db.select mysoils
124 cat|label|id|shortname|longname
125 1|Aab|||
126 2|Ba|2|Ba|Barnum silt loam
127 3|Bb|3|Bb|Barnum silt loam, channeled
128 4|BcB|4|BcB|Boneek silt loam, 2 to 6
129 5|BcC|5|BcC|Boneek silt loam, 6 to 9
130 ...
131
133 db.execute, db.in.ogr, db.select, v.db.update
134
135 GRASS SQL interface
136
138 Markus Neteler
139
141 Available at: v.db.join source code (history)
142
143 Accessed: Saturday Oct 28 18:19:21 2023
144
145 Main index | Vector index | Topics index | Keywords index | Graphical
146 index | Full index
147
148 © 2003-2023 GRASS Development Team, GRASS GIS 8.3.1 Reference Manual
149
150
151
152GRASS 8.3.1 v.db.join(1)